hexsha
stringlengths
40
40
size
int64
5
1.05M
ext
stringclasses
588 values
lang
stringclasses
305 values
max_stars_repo_path
stringlengths
3
363
max_stars_repo_name
stringlengths
5
118
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringdate
2015-01-01 00:00:35
2022-03-31 23:43:49
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 12:37:38
2022-03-31 23:59:52
max_issues_repo_path
stringlengths
3
363
max_issues_repo_name
stringlengths
5
118
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
134k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
363
max_forks_repo_name
stringlengths
5
135
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringdate
2015-01-01 00:01:02
2022-03-31 23:27:27
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 08:55:07
2022-03-31 23:59:24
content
stringlengths
5
1.05M
avg_line_length
float64
1.13
1.04M
max_line_length
int64
1
1.05M
alphanum_fraction
float64
0
1
704acdf7c3e763a32954104a4909037e9e302ce2
586
h
C
test/extensions/transport_sockets/tls/test_data/selfsigned2_cert_info.h
dcillera/envoy
cb54ba8eec26f768f8c1ae412113b07bacde7321
[ "Apache-2.0" ]
17,703
2017-09-14T18:23:43.000Z
2022-03-31T22:04:17.000Z
test/extensions/transport_sockets/tls/test_data/selfsigned2_cert_info.h
dcillera/envoy
cb54ba8eec26f768f8c1ae412113b07bacde7321
[ "Apache-2.0" ]
15,957
2017-09-14T16:38:22.000Z
2022-03-31T23:56:30.000Z
test/extensions/transport_sockets/tls/test_data/selfsigned2_cert_info.h
dcillera/envoy
cb54ba8eec26f768f8c1ae412113b07bacde7321
[ "Apache-2.0" ]
3,780
2017-09-14T18:58:47.000Z
2022-03-31T17:10:47.000Z
// NOLINT(namespace-envoy) constexpr char TEST_SELFSIGNED2_CERT_256_HASH[] = "7e33b4d81ef8518d9527967093b489d58da724f5b72c3330932789fbe0ed6089"; constexpr char TEST_SELFSIGNED2_CERT_1_HASH[] = "f07aea4eabfbad0d9b60053bd2fecc925733be5e"; constexpr char TEST_SELFSIGNED2_CERT_SPKI[] = "VlFyLiwhtbwHIPk7OHp4XGXGhCgDfYHOyiBEh0VGowM="; constexpr char TEST_SELFSIGNED2_CERT_SERIAL[] = "4c52a3eb3ce4407c53be51a18298b776fb0b70de"; constexpr char TEST_SELFSIGNED2_CERT_NOT_BEFORE[] = "Aug 20 16:57:49 2020 GMT"; constexpr char TEST_SELFSIGNED2_CERT_NOT_AFTER[] = "Aug 20 16:57:49 2022 GMT";
65.111111
93
0.846416
2a62e5e722e008514e9f4548846504ee01a17138
698
c
C
Examples/OptNomad/simulator3.c
lbianchi-lbl/psuade-lite
09d7ca75aba8a9e31e1fb5c3e134af046fca3460
[ "Apache-2.0" ]
14
2017-10-31T17:52:38.000Z
2022-03-04T05:16:56.000Z
Examples/OptNomad/simulator3.c
lbianchi-lbl/psuade-lite
09d7ca75aba8a9e31e1fb5c3e134af046fca3460
[ "Apache-2.0" ]
3
2021-03-10T22:10:32.000Z
2022-01-14T04:31:05.000Z
Examples/OptNomad/simulator3.c
lbianchi-lbl/psuade-lite
09d7ca75aba8a9e31e1fb5c3e134af046fca3460
[ "Apache-2.0" ]
12
2017-12-13T01:08:17.000Z
2020-11-26T22:58:08.000Z
#include <math.h> #include <stdio.h> #include <stdlib.h> main(int argc, char **argv) { int n, i; double *X, Y, pi=3.1415828; FILE *fIn = fopen(argv[1], "r"); FILE *fOut; if (fIn == NULL) { printf("CRIT3 ERROR - cannot open in/out files.\n"); exit(1); } fscanf(fIn, "%d", &n); X = (double *) malloc(n * sizeof(double)); for (i = 0; i < n; i++) fscanf(fIn, "%lg", &X[i]); fOut = fopen(argv[2], "w"); Y = 0.0; for (i = 0; i < n/2; i++) Y += (pow(X[i],2.0)-cos(0.2*pi*X[i])*10+ pow(X[i+15],2.0)-cos(0.2*pi*X[i+15])*10); Y *= 150.0; fprintf(fOut, "%24.16e\n", Y); free(X); fclose(fIn); fclose(fOut); }
21.8125
58
0.474212
0ba82524ad532bd4c59e7161c758a13e9145e3de
166
c
C
services/users-001/get-user-public-key-001-00000000.c
SabzCity/PersiaOS
ed5c1eda78b214c022b28d96bd9d25dc34f0411c
[ "ECL-2.0", "Apache-2.0" ]
13
2018-03-05T16:51:29.000Z
2021-01-22T12:33:39.000Z
services/users-001/get-user-public-key-001-00000000.c
GeniusesGroup/PersiaOS
ed5c1eda78b214c022b28d96bd9d25dc34f0411c
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
services/users-001/get-user-public-key-001-00000000.c
GeniusesGroup/PersiaOS
ed5c1eda78b214c022b28d96bd9d25dc34f0411c
[ "ECL-2.0", "Apache-2.0" ]
1
2021-06-25T17:11:40.000Z
2021-06-25T17:11:40.000Z
/* For license and copyright information please see LEGAL file in repository */ // Get user public key to any app request. [32] unsigned char GetUserPublicKey() {};
33.2
79
0.746988
93c9047405380fae900c4517b320f624fe49cdff
330
h
C
PrivateFrameworks/AirPortAssistant.framework/AirPortAssistantUINavigationController.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
PrivateFrameworks/AirPortAssistant.framework/AirPortAssistantUINavigationController.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
PrivateFrameworks/AirPortAssistant.framework/AirPortAssistantUINavigationController.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/AirPortAssistant.framework/AirPortAssistant */ @interface AirPortAssistantUINavigationController : UINavigationController - (bool)disablesAutomaticKeyboardDismissal; - (bool)shouldAutorotate; - (unsigned long long)supportedInterfaceOrientations; @end
27.5
87
0.839394
923a3a91e8e9b692d464dfc29a857361b2103443
9,071
c
C
src/Main/jkGame.c
MacSourcePorts/OpenJKDF2
4e129d1429ff549fbf95945d5675865a154aabde
[ "0BSD" ]
null
null
null
src/Main/jkGame.c
MacSourcePorts/OpenJKDF2
4e129d1429ff549fbf95945d5675865a154aabde
[ "0BSD" ]
null
null
null
src/Main/jkGame.c
MacSourcePorts/OpenJKDF2
4e129d1429ff549fbf95945d5675865a154aabde
[ "0BSD" ]
null
null
null
#include "jkGame.h" #include "General/stdPalEffects.h" #include "Engine/sith.h" #include "Engine/rdroid.h" #include "Engine/rdCache.h" #include "Engine/sithRender.h" #include "Engine/sithNet.h" #include "World/sithWorld.h" #include "World/jkPlayer.h" #include "World/sithSector.h" #include "Win95/Video.h" #include "Win95/sithDplay.h" #include "Platform/std3D.h" #include "Win95/stdDisplay.h" #include "Main/jkHud.h" #include "Main/jkHudInv.h" #include "Main/jkDev.h" #include "Engine/rdColormap.h" #include "Engine/sithCamera.h" #include "stdPlatform.h" #include "jk.h" int jkGame_Initialize() { sithWorld_SetSectionParser("jk", jkGame_ParseSection); jkGame_bInitted = 1; return 1; } int jkGame_ParseSection(sithWorld* a1, int a2) { return a2 == 0; } void jkGame_ForceRefresh() { sithCamera_Close(); rdCanvas_Free(Video_pCanvas); } void jkGame_Shutdown() { jkGame_bInitted = 0; } void jkGame_ScreensizeIncrease() { if ( Video_modeStruct.viewSizeIdx < 0xAu ) { #ifndef LINUX_TMP sithCamera_Close(); rdCanvas_Free(Video_pCanvas); ++Video_modeStruct.viewSizeIdx; Video_camera_related(); #endif } } void jkGame_ScreensizeDecrease() { if ( Video_modeStruct.viewSizeIdx ) { #ifndef LINUX_TMP sithCamera_Close(); rdCanvas_Free(Video_pCanvas); --Video_modeStruct.viewSizeIdx; Video_camera_related(); #endif } } void jkGame_SetDefaultSettings() { jkPlayer_setFullSubtitles = 0; jkPlayer_setDisableCutscenes = 0; jkPlayer_setRotateOverlayMap = 1; jkPlayer_setDrawStatus = 1; jkPlayer_setCrosshair = 0; jkPlayer_setSaberCam = 0; } #ifndef SDL2_RENDER int jkGame_Update() { int64_t v0; // rcx char *v1; // eax sithThing *v2; // esi int v3; // eax double v4; // st7 int result; // eax int v6; // [esp+1Ch] [ebp-1Ch] if ( Video_modeStruct.Video_8606C0 || Video_modeStruct.geoMode <= 2 ) stdDisplay_VBufferFill(Video_pMenuBuffer, Video_fillColor, 0); jkDev_DrawLog(); jkHudInv_ClearRects(); jkHud_ClearRects(0); v1 = stdDisplay_GetPalette(); stdPalEffects_UpdatePalette(v1); if ( Video_modeStruct.b3DAccel ) rdSetColorEffects(&stdPalEffects_state.effect); rdAdvanceFrame(); if ( Video_modeStruct.b3DAccel ) { sith_UpdateCamera(); } else { stdDisplay_VBufferLock(Video_pMenuBuffer); stdDisplay_VBufferLock(Video_pVbufIdk); sith_UpdateCamera(); stdDisplay_VBufferUnlock(Video_pVbufIdk); stdDisplay_VBufferUnlock(Video_pMenuBuffer); } jkPlayer_DrawPov(); rdFinishFrame(); /*if ( Main_bDispStats ) { v2 = sithWorld_pCurrentWorld->playerThing; ++Video_dword_5528A0; v3 = stdPlatform_GetTimeMsec(); v0 = v3 - Video_lastTimeMsec; Video_dword_5528A8 = v3; if ( (unsigned int)(v3 - Video_lastTimeMsec) > 0x3E8 ) { if ( Main_bDispStats ) { v6 = v2->sector->id; Video_flt_55289C = (double)(Video_dword_5528A0 - Video_dword_5528A4) * 1000.0 / (double)v0; _sprintf( std_genBuffer, "%02.3f (%02d%%)f %3ds %3da %3dz %4dp %3d curSector %3d fo", Video_flt_55289C, (unsigned int)(__int64)((double)(unsigned int)jkGame_updateMsecsTotal / (double)(int)v0 * 100.0), sithRender_surfacesDrawn, sithRender_831980, sithRender_831984, rdCache_drawnFaces, v6, net_things_idx); if ( net_isMulti ) _sprintf(&std_genBuffer[_strlen(std_genBuffer)], " %d m %d b", sithDplay_dword_8321F4, sithDplay_dword_8321F0); jkDev_sub_41FC40(100, std_genBuffer); v3 = Video_dword_5528A8; } Video_lastTimeMsec = v3; Video_dword_5528A4 = Video_dword_5528A0; jkGame_dword_552B5C = 0; jkGame_updateMsecsTotal = 0; sithDplay_dword_8321F0 = 0; sithDplay_dword_8321F4 = 0; } } else if ( Main_bFrameRate ) { ++Video_dword_5528A0; Video_dword_5528A8 = stdPlatform_GetTimeMsec(); if ( (unsigned int)(Video_dword_5528A8 - Video_lastTimeMsec) > 0x3E8 ) { v4 = (double)(Video_dword_5528A0 - Video_dword_5528A4) * 1000.0 / (double)(unsigned int)(Video_dword_5528A8 - Video_lastTimeMsec); Video_flt_55289C = v4; _sprintf(std_genBuffer, "%02.3f", v4); jkDev_sub_41FC40(100, std_genBuffer); Video_lastTimeMsec = Video_dword_5528A8; Video_dword_5528A4 = Video_dword_5528A0; } }*/ if ( (playerThings[playerThingIdx].actorThing->actorParams.typeflags & THING_TYPEFLAGS_800000) == 0 ) jkHud_Draw(); jkDev_sub_41F950(); jkHudInv_Draw(); if ( Video_modeStruct.b3DAccel ) std3D_DrawOverlay(); if ( Video_modeStruct.b3DAccel ) result = stdDisplay_DDrawGdiSurfaceFlip(); else result = stdDisplay_VBufferCopy(Video_pOtherBuf, Video_pMenuBuffer, 0, 0, 0, 0); return result; } #else int jkGame_Update() { int64_t v0; // rcx char *v1; // eax sithThing *v2; // esi int v3; // eax double v4; // st7 int result; // eax int v6; // [esp+1Ch] [ebp-1Ch] // HACK Video_modeStruct.b3DAccel = 1; //if ( Video_modeStruct.Video_8606C0 || Video_modeStruct.geoMode <= 2 ) stdDisplay_VBufferFill(Video_pMenuBuffer, Video_fillColor, 0); jkDev_DrawLog(); jkHudInv_ClearRects(); jkHud_ClearRects(0); v1 = stdDisplay_GetPalette(); stdPalEffects_UpdatePalette(v1); //if ( Video_modeStruct.b3DAccel ) rdSetColorEffects(&stdPalEffects_state.effect); _memcpy(stdDisplay_masterPalette, sithWorld_pCurrentWorld->colormaps->colors, 0x300); rdAdvanceFrame(); //if ( Video_modeStruct.b3DAccel ) { sith_UpdateCamera(); } /*else { stdDisplay_VBufferLock(Video_pMenuBuffer); stdDisplay_VBufferLock(Video_pVbufIdk); sith_UpdateCamera(); stdDisplay_VBufferUnlock(Video_pVbufIdk); stdDisplay_VBufferUnlock(Video_pMenuBuffer); }*/ jkPlayer_DrawPov(); /*if ( Main_bDispStats ) { v2 = sithWorld_pCurrentWorld->playerThing; ++Video_dword_5528A0; v3 = stdPlatform_GetTimeMsec(); v0 = v3 - Video_lastTimeMsec; Video_dword_5528A8 = v3; if ( (unsigned int)(v3 - Video_lastTimeMsec) > 0x3E8 ) { if ( Main_bDispStats ) { v6 = v2->sector->id; Video_flt_55289C = (double)(Video_dword_5528A0 - Video_dword_5528A4) * 1000.0 / (double)v0; _sprintf( std_genBuffer, "%02.3f (%02d%%)f %3ds %3da %3dz %4dp %3d curSector %3d fo", Video_flt_55289C, (unsigned int)(__int64)((double)(unsigned int)jkGame_updateMsecsTotal / (double)(int)v0 * 100.0), sithRender_surfacesDrawn, sithRender_831980, sithRender_831984, rdCache_drawnFaces, v6, net_things_idx); if ( net_isMulti ) _sprintf(&std_genBuffer[_strlen(std_genBuffer)], " %d m %d b", sithDplay_dword_8321F4, sithDplay_dword_8321F0); jkDev_sub_41FC40(100, std_genBuffer); v3 = Video_dword_5528A8; } Video_lastTimeMsec = v3; Video_dword_5528A4 = Video_dword_5528A0; jkGame_dword_552B5C = 0; jkGame_updateMsecsTotal = 0; sithDplay_dword_8321F0 = 0; sithDplay_dword_8321F4 = 0; } } else if ( Main_bFrameRate ) { ++Video_dword_5528A0; Video_dword_5528A8 = stdPlatform_GetTimeMsec(); if ( (unsigned int)(Video_dword_5528A8 - Video_lastTimeMsec) > 0x3E8 ) { v4 = (double)(Video_dword_5528A0 - Video_dword_5528A4) * 1000.0 / (double)(unsigned int)(Video_dword_5528A8 - Video_lastTimeMsec); Video_flt_55289C = v4; _sprintf(std_genBuffer, "%02.3f", v4); jkDev_sub_41FC40(100, std_genBuffer); Video_lastTimeMsec = Video_dword_5528A8; Video_dword_5528A4 = Video_dword_5528A0; } }*/ if ( (playerThings[playerThingIdx].actorThing->actorParams.typeflags & THING_TYPEFLAGS_800000) == 0 ) jkHud_Draw(); jkDev_sub_41F950(); jkHudInv_Draw(); //if ( Video_modeStruct.b3DAccel ) // std3D_DrawOverlay(); std3D_DrawMenu(); rdFinishFrame(); if ( Video_modeStruct.b3DAccel ) result = stdDisplay_DDrawGdiSurfaceFlip(); else result = stdDisplay_VBufferCopy(Video_pOtherBuf, Video_pMenuBuffer, 0, 0, 0, 0); return result; } #endif
30.749153
142
0.618013
7f958ac7fa2802a1c2e61af03ae151fca51a7792
586
c
C
03/printBack/pbVet.c
itacirgabral/lp
87e49b1ea24e0fe5058f8d01600cd948afcd8d23
[ "MIT" ]
null
null
null
03/printBack/pbVet.c
itacirgabral/lp
87e49b1ea24e0fe5058f8d01600cd948afcd8d23
[ "MIT" ]
null
null
null
03/printBack/pbVet.c
itacirgabral/lp
87e49b1ea24e0fe5058f8d01600cd948afcd8d23
[ "MIT" ]
1
2016-01-27T21:41:16.000Z
2016-01-27T21:41:16.000Z
#include "stdio.h" #include "stdlib.h" char *frase; char *palavra; char letra; int main(){ // // frase = (char *) malloc(128*sizeof(char)); palavra = (char *) malloc(16*sizeof(char)); // // printf("escreva uma frase\n"); scanf("%[^\n]s",frase); printf("vc escreveu:\n%s\n", frase); // // printf("escreva uma palavra\n"); scanf(" %s", palavra); printf("vc escreveu:\n%s\n", palavra); // // printf("digite uma letra\n"); scanf(" %c", &letra); printf("vc digitou:\n%c\n", letra); // // return 0; }
17.757576
47
0.517065
36e7346e1c5576b382b7e35e7b99462fddd52e08
5,181
c
C
openldap/libraries/libldap_r/thr_stub.c
kbore/pbis-open
a05eb9309269b6402b4d6659bc45961986ea5eab
[ "Apache-2.0" ]
372
2016-10-28T10:50:35.000Z
2022-03-18T19:54:37.000Z
openldap/libraries/libldap_r/thr_stub.c
kbore/pbis-open
a05eb9309269b6402b4d6659bc45961986ea5eab
[ "Apache-2.0" ]
317
2016-11-02T17:41:48.000Z
2021-11-08T20:28:19.000Z
openldap/libraries/libldap_r/thr_stub.c
kenferrara/pbis-open
690c325d947b2bf6fb3032f9d660e41b94aea4be
[ "Apache-2.0" ]
107
2016-11-03T19:25:16.000Z
2022-03-20T21:15:22.000Z
/* thr_stub.c - stubs for the threads */ /* $OpenLDAP: pkg/ldap/libraries/libldap_r/thr_stub.c,v 1.27.2.9 2009/01/22 00:00:56 kurt Exp $ */ /* This work is part of OpenLDAP Software <http://www.openldap.org/>. * * Copyright 1998-2009 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in file LICENSE in the * top-level directory of the distribution or, alternatively, at * <http://www.OpenLDAP.org/license.html>. */ #include "portable.h" #if defined( NO_THREADS ) #include "ldap_pvt_thread.h" /* Get the thread interface */ #define LDAP_THREAD_IMPLEMENTATION #define LDAP_THREAD_POOL_IMPLEMENTATION #include "ldap_thr_debug.h" /* May rename the symbols defined below */ /*********************************************************************** * * * no threads package defined for this system - fake ok returns from * * all threads routines (making it single-threaded). * * * ***********************************************************************/ int ldap_int_thread_initialize( void ) { return 0; } int ldap_int_thread_destroy( void ) { return 0; } static void* ldap_int_status = NULL; int ldap_pvt_thread_create( ldap_pvt_thread_t * thread, int detach, void *(*start_routine)(void *), void *arg) { if( ! detach ) ldap_int_status = NULL; start_routine( arg ); return 0; } void ldap_pvt_thread_exit( void *retval ) { if( retval != NULL ) { ldap_int_status = retval; } return; } int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **status ) { if(status != NULL) *status = ldap_int_status; return 0; } int ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) { return 0; } int ldap_pvt_thread_yield( void ) { return 0; } int ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) { return 0; } int ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond ) { return 0; } int ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) { return 0; } int ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) { return 0; } int ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, ldap_pvt_thread_mutex_t *mutex ) { return 0; } int ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) { return 0; } int ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) { return 0; } int ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) { return 0; } int ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex ) { return 0; } int ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) { return 0; } /* * NO_THREADS requires a separate tpool implementation since * generic ldap_pvt_thread_pool_wrapper loops forever. */ int ldap_pvt_thread_pool_init ( ldap_pvt_thread_pool_t *pool_out, int max_concurrency, int max_pending ) { *pool_out = (ldap_pvt_thread_pool_t) 0; return(0); } int ldap_pvt_thread_pool_submit ( ldap_pvt_thread_pool_t *pool, ldap_pvt_thread_start_t *start_routine, void *arg ) { (start_routine)(NULL, arg); return(0); } int ldap_pvt_thread_pool_maxthreads ( ldap_pvt_thread_pool_t *tpool, int max_threads ) { return(0); } int ldap_pvt_thread_pool_query( ldap_pvt_thread_pool_t *tpool, ldap_pvt_thread_pool_param_t param, void *value ) { *(int *)value = -1; return(-1); } int ldap_pvt_thread_pool_backload ( ldap_pvt_thread_pool_t *pool ) { return(0); } int ldap_pvt_thread_pool_destroy ( ldap_pvt_thread_pool_t *pool, int run_pending ) { return(0); } int ldap_pvt_thread_pool_getkey ( void *ctx, void *key, void **data, ldap_pvt_thread_pool_keyfree_t **kfree ) { return(0); } int ldap_pvt_thread_pool_setkey ( void *ctx, void *key, void *data, ldap_pvt_thread_pool_keyfree_t *kfree, void **olddatap, ldap_pvt_thread_pool_keyfree_t **oldkfreep ) { if ( olddatap ) *olddatap = NULL; if ( oldkfreep ) *oldkfreep = 0; return(0); } void ldap_pvt_thread_pool_purgekey( void *key ) { } int ldap_pvt_thread_pool_pause ( ldap_pvt_thread_pool_t *tpool ) { return(0); } int ldap_pvt_thread_pool_resume ( ldap_pvt_thread_pool_t *tpool ) { return(0); } int ldap_pvt_thread_pool_pausing( ldap_pvt_thread_pool_t *tpool ) { return(0); } ldap_pvt_thread_pool_pausecheck( ldap_pvt_thread_pool_t *tpool ) { return(0); } void *ldap_pvt_thread_pool_context( ) { return(NULL); } void ldap_pvt_thread_pool_context_reset( void *vctx ) { } ldap_pvt_thread_t ldap_pvt_thread_self( void ) { return(0); } int ldap_pvt_thread_key_create( ldap_pvt_thread_key_t *key ) { return(0); } int ldap_pvt_thread_key_destroy( ldap_pvt_thread_key_t key ) { return(0); } int ldap_pvt_thread_key_setdata( ldap_pvt_thread_key_t key, void *data ) { return(0); } int ldap_pvt_thread_key_getdata( ldap_pvt_thread_key_t key, void **data ) { return(0); } ldap_pvt_thread_t ldap_pvt_thread_pool_tid( void *vctx ) { return(0); } #endif /* NO_THREADS */
18.115385
98
0.705655
cfc3d23bc0a9dc8f3369bbe8c2dbec70ab0baf36
6,083
h
C
haproxy-ss-20130902/include/types/global.h
Jimbly/node-https-websocket-loadbalance-test
d371ddc36b0bd3fbb07273eeeec0895d7864f507
[ "MIT" ]
1
2019-05-14T16:18:14.000Z
2019-05-14T16:18:14.000Z
haproxy-ss-20130902/include/types/global.h
Jimbly/node-https-websocket-loadbalance-test
d371ddc36b0bd3fbb07273eeeec0895d7864f507
[ "MIT" ]
null
null
null
haproxy-ss-20130902/include/types/global.h
Jimbly/node-https-websocket-loadbalance-test
d371ddc36b0bd3fbb07273eeeec0895d7864f507
[ "MIT" ]
null
null
null
/* * include/types/global.h * Global variables. * * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu * * 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, version 2.1 * exclusively. * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _TYPES_GLOBAL_H #define _TYPES_GLOBAL_H #include <netinet/in.h> #include <common/config.h> #include <types/freq_ctr.h> #include <types/listener.h> #include <types/proxy.h> #include <types/task.h> #ifndef UNIX_MAX_PATH #define UNIX_MAX_PATH 108 #endif /* modes of operation (global.mode) */ #define MODE_DEBUG 0x01 #define MODE_DAEMON 0x02 #define MODE_QUIET 0x04 #define MODE_CHECK 0x08 #define MODE_VERBOSE 0x10 #define MODE_STARTING 0x20 #define MODE_FOREGROUND 0x40 #define MODE_SYSTEMD 0x80 /* list of last checks to perform, depending on config options */ #define LSTCHK_CAP_BIND 0x00000001 /* check that we can bind to any port */ #define LSTCHK_CTTPROXY 0x00000002 /* check that tproxy is enabled */ #define LSTCHK_NETADM 0x00000004 /* check that we have CAP_NET_ADMIN */ /* Global tuning options */ /* available polling mechanisms */ #define GTUNE_USE_SELECT (1<<0) #define GTUNE_USE_POLL (1<<1) #define GTUNE_USE_EPOLL (1<<2) #define GTUNE_USE_KQUEUE (1<<3) /* platform-specific options */ #define GTUNE_USE_SPLICE (1<<4) /* Access level for a stats socket */ #define ACCESS_LVL_NONE 0 #define ACCESS_LVL_USER 1 #define ACCESS_LVL_OPER 2 #define ACCESS_LVL_ADMIN 3 /* FIXME : this will have to be redefined correctly */ struct global { #ifdef USE_OPENSSL char *crt_base; /* base directory path for certificates */ char *ca_base; /* base directory path for CAs and CRLs */ #endif int uid; int gid; int nbproc; int maxconn, hardmaxconn; #ifdef USE_OPENSSL int maxsslconn; char *listen_default_ciphers; char *connect_default_ciphers; #endif struct freq_ctr conn_per_sec; struct freq_ctr comp_bps_in; /* bytes per second, before http compression */ struct freq_ctr comp_bps_out; /* bytes per second, after http compression */ int cps_lim, cps_max; int comp_rate_lim; /* HTTP compression rate limit */ int maxpipes; /* max # of pipes */ int maxsock; /* max # of sockets */ int rlimit_nofile; /* default ulimit-n value : 0=unset */ int rlimit_memmax; /* default ulimit-d in megs value : 0=unset */ long maxzlibmem; /* max RAM for zlib in bytes */ int mode; unsigned int req_count; /* HTTP request counter for logs and unique_id */ int last_checks; int spread_checks; char *chroot; char *pidfile; char *node, *desc; /* node name & description */ char *log_tag; /* name for syslog */ struct list logsrvs; char *log_send_hostname; /* set hostname in syslog header */ struct { int maxpollevents; /* max number of poll events at once */ int maxaccept; /* max number of consecutive accept() */ int options; /* various tuning options */ int recv_enough; /* how many input bytes at once are "enough" */ int bufsize; /* buffer size in bytes, defaults to BUFSIZE */ int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */ int client_sndbuf; /* set client sndbuf to this value if not null */ int client_rcvbuf; /* set client rcvbuf to this value if not null */ int server_sndbuf; /* set server sndbuf to this value if not null */ int server_rcvbuf; /* set server rcvbuf to this value if not null */ int chksize; /* check buffer size in bytes, defaults to BUFSIZE */ int pipesize; /* pipe size in bytes, system defaults if zero */ int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */ int cookie_len; /* max length of cookie captures */ #ifdef USE_OPENSSL int sslcachesize; /* SSL cache size in session, defaults to 20000 */ unsigned int ssllifetime; /* SSL session lifetime in seconds */ unsigned int ssl_max_record; /* SSL max record size */ #endif #ifdef USE_ZLIB int zlibmemlevel; /* zlib memlevel */ int zlibwindowsize; /* zlib window size */ #endif int comp_maxlevel; /* max HTTP compression level */ } tune; struct { char *prefix; /* path prefix of unix bind socket */ struct { /* UNIX socket permissions */ uid_t uid; /* -1 to leave unchanged */ gid_t gid; /* -1 to leave unchanged */ mode_t mode; /* 0 to leave unchanged */ } ux; } unix_bind; #ifdef USE_CPU_AFFINITY unsigned long cpu_map[32]; /* list of CPU masks for the 32 first processes */ #endif struct proxy *stats_fe; /* the frontend holding the stats settings */ }; extern struct global global; extern int pid; /* current process id */ extern int relative_pid; /* process id starting at 1 */ extern int actconn; /* # of active sessions */ extern int listeners; extern int jobs; /* # of active jobs */ extern struct chunk trash; extern char *swap_buffer; extern int nb_oldpids; /* contains the number of old pids found */ extern const int zero; extern const int one; extern const struct linger nolinger; extern int stopping; /* non zero means stopping in progress */ extern char hostname[MAX_HOSTNAME_LEN]; extern char localpeer[MAX_HOSTNAME_LEN]; extern struct list global_listener_queue; /* list of the temporarily limited listeners */ extern struct task *global_listener_queue_task; #endif /* _TYPES_GLOBAL_H */ /* * Local variables: * c-indent-level: 8 * c-basic-offset: 8 * End: */
36.208333
89
0.700641
9adb9eccf5978714760e00fe511022eee4be39b0
4,150
h
C
src/catchup/CatchupWork.h
V5DF8/stellar-core
3fb2dc6bea41ed9160313f856e57451897f68cd9
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
10
2019-07-01T19:09:58.000Z
2022-03-13T14:39:06.000Z
src/catchup/CatchupWork.h
V5DF8/stellar-core
3fb2dc6bea41ed9160313f856e57451897f68cd9
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
4
2021-04-09T20:33:39.000Z
2022-03-07T18:33:58.000Z
src/catchup/CatchupWork.h
V5DF8/stellar-core
3fb2dc6bea41ed9160313f856e57451897f68cd9
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
4
2015-04-11T02:33:46.000Z
2021-11-24T10:27:28.000Z
// Copyright 2017 Stellar Development Foundation and contributors. Licensed // under the Apache License, Version 2.0. See the COPYING file at the root // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 #pragma once #include "catchup/CatchupConfiguration.h" #include "catchup/VerifyLedgerChainWork.h" #include "history/HistoryArchive.h" #include "historywork/GetHistoryArchiveStateWork.h" #include "work/Work.h" #include "work/WorkSequence.h" namespace stellar { class HistoryManager; class Bucket; class TmpDir; class CatchupRange; using WorkSeqPtr = std::shared_ptr<WorkSequence>; // CatchupWork does all the necessary work to perform any type of catchup. // It accepts CatchupConfiguration structure to know from which ledger to which // one do the catchup and if it involves only applying ledgers or ledgers and // buckets. // // First thing it does is to get a history state which allows to calculate // proper destination ledger (in case CatchupConfiguration::CURRENT) was used // and to get list of buckets that should be in database on that ledger. // // Next step is downloading and verifying ledgers (if verifyMode is set to // VERIFY_BUFFERED_LEDGERS it can also verify against ledgers currently // buffered in LedgerManager). // // Then, depending on configuration, it can download, verify and apply buckets // (as in MINIMAL and RECENT catchups), and then download and apply // transactions (as in COMPLETE and RECENT catchups). // // After that, catchup is done and node can replay buffered ledgers and take // part in consensus protocol. class CatchupWork : public Work { protected: HistoryArchiveState mLocalState; std::unique_ptr<TmpDir> mDownloadDir; std::map<std::string, std::shared_ptr<Bucket>> mBuckets; void doReset() override; BasicWork::State doWork() override; void onFailureRaise() override; void onSuccess() override; public: // Resume application when publish queue shrinks down to this many // checkpoints static uint32_t const PUBLISH_QUEUE_UNBLOCK_APPLICATION; // Allow at most this many checkpoints in the publish queue while catching // up. If the queue grows too big, ApplyCheckpointWork will wait until // enough snapshots were published, and unblock itself. static uint32_t const PUBLISH_QUEUE_MAX_SIZE; CatchupWork(Application& app, CatchupConfiguration catchupConfiguration, std::shared_ptr<HistoryArchive> archive = nullptr); virtual ~CatchupWork(); std::string getStatus() const override; CatchupConfiguration const& getCatchupConfiguration() const { return mCatchupConfiguration; } private: LedgerNumHashPair mLastClosedLedgerHashPair; CatchupConfiguration const mCatchupConfiguration; LedgerHeaderHistoryEntry mVerifiedLedgerRangeStart; LedgerHeaderHistoryEntry mLastApplied; std::shared_ptr<HistoryArchive> mArchive; bool mBucketsAppliedEmitted{false}; bool mTransactionsVerifyEmitted{false}; std::shared_ptr<GetHistoryArchiveStateWork> mGetHistoryArchiveStateWork; std::shared_ptr<GetHistoryArchiveStateWork> mGetBucketStateWork; WorkSeqPtr mDownloadVerifyLedgersSeq; std::promise<LedgerNumHashPair> mRangeEndPromise; std::shared_future<LedgerNumHashPair> mRangeEndFuture; std::shared_ptr<VerifyLedgerChainWork> mVerifyLedgers; std::shared_ptr<Work> mVerifyTxResults; WorkSeqPtr mBucketVerifyApplySeq; std::shared_ptr<Work> mTransactionsVerifyApplySeq; std::shared_ptr<BasicWork> mApplyBufferedLedgersWork; WorkSeqPtr mCatchupSeq; std::shared_ptr<BasicWork> mCurrentWork; bool hasAnyLedgersToCatchupTo() const; bool alreadyHaveBucketsHistoryArchiveState(uint32_t atCheckpoint) const; void assertBucketState(); void downloadVerifyLedgerChain(CatchupRange const& catchupRange, LedgerNumHashPair rangeEnd); WorkSeqPtr downloadApplyBuckets(); void downloadApplyTransactions(CatchupRange const& catchupRange); void downloadVerifyTxResults(CatchupRange const& catchupRange); BasicWork::State runCatchupStep(); }; }
36.725664
79
0.767952
3c3c8624fff7e4213490de4c14450095845c7ac7
340
h
C
zhihuDaily/Classes/Setting/View/SYSettingCell.h
WiitterSimithYU/zhihuDaily-master
29f25a86b5725b5a7848d826fcea00681791916f
[ "MIT" ]
210
2016-03-01T07:51:51.000Z
2022-01-04T06:54:16.000Z
zhihuDaily/Classes/Setting/View/SYSettingCell.h
WiitterSimithYU/zhihuDaily-master
29f25a86b5725b5a7848d826fcea00681791916f
[ "MIT" ]
2
2016-03-19T07:56:33.000Z
2018-05-21T00:59:53.000Z
zhihuDaily/Classes/Setting/View/SYSettingCell.h
WiitterSimithYU/zhihuDaily-master
29f25a86b5725b5a7848d826fcea00681791916f
[ "MIT" ]
57
2016-03-01T07:54:50.000Z
2019-11-03T02:48:07.000Z
// // SYSettingCell.h // zhihuDaily // // Created by yang on 16/2/27. // Copyright © 2016年 yang. All rights reserved. // #import <UIKit/UIKit.h> #import "SYSettingItem.h" @interface SYSettingCell : UITableViewCell @property (nonatomic, strong) SYSettingItem *item; + (instancetype)cellWithTableView:(UITableView *)tableView; @end
17
59
0.720588
965e6dd02601b2d9f9aa402dc0955313e903addd
3,003
h
C
Core/Code/Interactions/mitkDisplayVectorInteractorLevelWindow.h
danielknorr/MITK
b1b9780b2a6671d8118313c5ef71e9aa128362be
[ "BSD-3-Clause" ]
1
2017-03-05T05:29:32.000Z
2017-03-05T05:29:32.000Z
Core/Code/Interactions/mitkDisplayVectorInteractorLevelWindow.h
danielknorr/MITK
b1b9780b2a6671d8118313c5ef71e9aa128362be
[ "BSD-3-Clause" ]
null
null
null
Core/Code/Interactions/mitkDisplayVectorInteractorLevelWindow.h
danielknorr/MITK
b1b9780b2a6671d8118313c5ef71e9aa128362be
[ "BSD-3-Clause" ]
2
2020-10-27T06:51:00.000Z
2020-10-27T06:51:01.000Z
/*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKDisplayVectorInteractorLevelWindow_H_HEADER_INCLUDED_C10DC4EB #define MITKDisplayVectorInteractorLevelWindow_H_HEADER_INCLUDED_C10DC4EB #include <MitkCoreExports.h> #include "mitkBaseRenderer.h" #include "mitkStateMachine.h" namespace mitk { class Operation; class OperationActor; /** * @brief Interactor for adjusting both level- and window-values for an image * * This class implements an Interactor for adjusting the LevelWindow. It is defined by the 'LevelWindow'-statemachine which maps 'initmove' to right mousebutton pressed, * 'levelwindow' to right mousebutton and move and 'finishmove' to right mousebutton released. * * Using this tool, it is possible to increase the 'level'-value of the selected image * ( if no image has the 'selected'-property == true, the first image in the DataStorage is used ) * by moving the mouse right and decreasing the level by moving the mouse to the left. * * The 'window'-value and also be adjusted by moving the mouse-curser up (increase) and down (decrease). * * @ingroup MITK_CORE_EXPORT **/ class MITK_CORE_EXPORT DisplayVectorInteractorLevelWindow : public StateMachine { public: mitkClassMacro(DisplayVectorInteractorLevelWindow, StateMachine); mitkNewMacro1Param(Self, const char*); itkEventMacro( InteractionEvent, itk::AnyEvent ); itkEventMacro( StartInteractionEvent, InteractionEvent ); itkEventMacro( EndInteractionEvent, InteractionEvent ); //static Pointer New(const char* type) //{ // Pointer smartPtr = new DisplayVectorInteractorLevelWindow ( type ); // smartPtr->UnRegister(); // return smartPtr; //} /** * @brief Method derived from OperationActor to recieve and execute operations **/ virtual void ExecuteOperation(Operation* operation); protected: /** * @brief Default Constructor **/ DisplayVectorInteractorLevelWindow(const char * type); /** * @brief Default Destructor **/ virtual ~DisplayVectorInteractorLevelWindow(); /** * @brief Method derived from StateMachine to implement the own actions **/ virtual bool ExecuteAction(Action* action, mitk::StateEvent const* stateEvent); private: BaseRenderer::Pointer m_Sender; mitk::Point2D m_StartDisplayCoordinate; mitk::Point2D m_LastDisplayCoordinate; mitk::Point2D m_CurrentDisplayCoordinate; }; } // namespace mitk #endif /* MITKDISPLAYVECTORINTERACTOR_H_HEADER_INCLUDED_C10DC4EB */
30.642857
170
0.712621
3259ccf21b5be6009dd9c0642b10d96a817f01a0
3,369
h
C
src/Models/TransactionPoolModel.h
exploshot/fork_qwertycoin-zero
b22803590568ad8652c0c116ab00228d587afce9
[ "MIT" ]
8
2019-03-04T12:04:14.000Z
2021-01-31T12:11:38.000Z
src/Models/TransactionPoolModel.h
8134aff32f/qwertycoin-zero
e9f1c16789dfca110c5b5fee7d23c1a05621b2c6
[ "MIT" ]
11
2019-03-29T14:01:32.000Z
2020-05-17T09:13:30.000Z
src/Models/TransactionPoolModel.h
8134aff32f/qwertycoin-zero
e9f1c16789dfca110c5b5fee7d23c1a05621b2c6
[ "MIT" ]
10
2019-04-06T09:04:14.000Z
2021-01-31T12:11:50.000Z
// Copyright (c) 2015-2017, The Bytecoin developers // Copyright (c) 2017-2018, The Karbo developers // Copyright (c) 2019, The Qwertycoin developers // // This file is part of Qwertycoin. // // Qwertycoin 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 3 of the License, or // (at your option) any later version. // // Qwertycoin 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 Qwertycoin. If not, see <http://www.gnu.org/licenses/>. #pragma once #include <QAbstractItemModel> #include "IBlockChainExplorerAdapter.h" #include "ICryptoNoteAdapter.h" namespace CryptoNote { struct TransactionDetails; } namespace WalletGui { class ICryptoNoteAdapter; class TransactionPoolModel : public QAbstractItemModel, public IBlockChainExplorerAdapterObserver, public ICryptoNoteAdapterObserver { Q_OBJECT Q_DISABLE_COPY(TransactionPoolModel) Q_ENUMS(Columns) Q_ENUMS(Roles) public: enum Columns { COLUMN_TIME = 0, COLUMN_HASH, COLUMN_AMOUNT, COLUMN_FEE, COLUMN_SIZE, COLUMN_MIXIN, COLUMN_PAYMENT_ID }; enum Roles { ROLE_TIME = Qt::UserRole, ROLE_AMOUNT, ROLE_FEE, ROLE_SIZE, ROLE_HASH, ROLE_MIXIN, ROLE_PAYMENT_ID, ROLE_COLUMN }; TransactionPoolModel(ICryptoNoteAdapter* _cryptoNoteAdapter, QObject* _parent); ~TransactionPoolModel(); Qt::ItemFlags flags(const QModelIndex &_index) const override; int columnCount(const QModelIndex &_parent = QModelIndex()) const override; int rowCount(const QModelIndex &_parent = QModelIndex()) const override; QVariant headerData(int _section, Qt::Orientation _orientation, int _role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &_index, int _role = Qt::DisplayRole) const override; QModelIndex index(int _row, int _column, const QModelIndex &_parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &_index) const override; // IBlockChainExplorerAdapterObserver Q_SLOT virtual void blockChainUpdated(const QVector<CryptoNote::BlockDetails>& _newBlocks, const QVector<CryptoNote::BlockDetails>& _orphanedBlocks) override; Q_SLOT virtual void poolUpdated(const QVector<CryptoNote::TransactionDetails>& _newTransactions, const QVector<Crypto::Hash>& _removedTransactions) override; Q_SLOT virtual void blockchainSynchronized(const CryptoNote::BlockDetails& _topBlock) override; // ICryptoNoteAdapterObserver Q_SLOT virtual void cryptoNoteAdapterInitCompleted(int _status) override; Q_SLOT virtual void cryptoNoteAdapterDeinitCompleted() override; static int findProxyColumn(QAbstractItemModel* _proxyModel, int _originColumn); private: ICryptoNoteAdapter* m_cryptoNoteAdapter; QList<QByteArray> m_rowHashes; QHash<QByteArray, CryptoNote::TransactionDetails> m_transactions; bool m_isSynchronized; const int m_columnCount; QVariant getDisplayRole(const QModelIndex& _index) const; QVariant getUserRole(const QModelIndex& _index, int _role) const; Q_SIGNALS: void initCompleted(); }; }
37.853933
134
0.789255
d0ea8cfc7d76e09a672fa838e0743417aa9a6c75
3,645
h
C
dbj++/util/dbj_optional_any.h
dbj-systems/dbj-laboratorium
ea497f9b68b78797d11bdc41b0f23a310c9325a9
[ "CC0-1.0" ]
2
2019-09-22T12:13:20.000Z
2019-10-24T04:17:33.000Z
dbj++/util/dbj_optional_any.h
dbj-systems/dbj-laboratorium
ea497f9b68b78797d11bdc41b0f23a310c9325a9
[ "CC0-1.0" ]
9
2019-03-06T06:52:56.000Z
2021-06-14T16:54:11.000Z
dbj++/util/dbj_optional_any.h
dbj-systems/dbj-laboratorium
ea497f9b68b78797d11bdc41b0f23a310c9325a9
[ "CC0-1.0" ]
1
2019-10-18T14:16:27.000Z
2019-10-18T14:16:27.000Z
#pragma once namespace dbj::util { #pragma region dealing with optional<T> /* Why std::optional? Examples: 1. It is extremely preferable to having something like a std::optional<std::string> for each string member! std::optional gives you data locality, which is great for performance. 2. std::optional<int> try_parse_int(std::string ) above is **much** simpler/safer/faster vs int * try_parse_int(std::string ) or bool try_parse_int(std::string , int & ) 3. Avoiding '-1' as 'special value' std::optional<int> find_in_string(std::string , std::string ); it appears bellow is all we need to handle the optional<T> in a comfortable safer manner optional<T> actually never looses it's 'T' bellow is with added functionality of user defined dflt optional val */ template<typename T> inline T optival (std::optional<T> opt, T dflt_ = T{}) noexcept // daring { return opt.value_or(dflt_); } //// same as above but adding "meta default" //// and delivering optional<T> instance //// returning the two above in an std::pair // template<typename T> // inline auto optional_pair(T defval = {}) // { //// here we enforce type requirements for T //// we specificaly bar the pointers handling //// smart pointers are made for that // static_assert( // !is_pointer<T>::value, // __FILE__ " optional_handle -- T can not be a pointer" // ); //// somewhat controversial requirement ;) //// https://foonathan.net/blog/2018/07/12/optional-reference.html // static_assert( // !is_reference_v <T>, // __FILE__ " optional_handle -- T can not be a reference" // ); //// here add static_assert's to narrow the choice of the type allowed // static_assert(std::is_constructible_v<T>, // "\n\n" __FUNCSIG__ "\nT must be constructible\n"); // static_assert(std::is_copy_constructible_v<T>, // "\n\n" __FUNCSIG__ "\nT must be copy constructible\n"); // static_assert(std::is_move_constructible_v < T >, // "\n\n" __FUNCSIG__ "\nT must be move constructible\n"); // // return std::make_pair( //// the first //// pay attention: we do not need "functor" here // [=] // (std::optional<T> opt_, std::optional<T> dflt_ = std::nullopt) // noexcept -> T // { // T meta_def{ defval }; // return opt_.value_or(dflt_.value_or(meta_def)); // }, // // the second // std::optional<T>{} // ); // } // optional_pair #pragma endregion #pragma region dealing with std::any /* any and optional and pair working together this makes the any much more usefull */ template<typename T> auto any_opt(T const & v_ = 0) { using namespace std; using value_type = std::decay_t< T >; static_assert(!std::is_reference_v< value_type >, "\n\n[dbj any_opt] Can not hold a reference type\n"); static_assert(!std::is_array_v< value_type >, "\n\n[dbj any_opt] Can not hold an array type\n"); static_assert(std::is_constructible_v < value_type >, "\n\n[dbj any_opt] T must be constructible\n"); static_assert(std::is_move_constructible_v < value_type >, "\n\n[dbj any_opt] T must be move constructible\n"); (void)noexcept(v_); // pacify the warning about unused using optitype = std::optional< T >; // the any auto any_ = any(v_); // now the lambda auto lambada_ = [=]() -> optitype { if (any_.has_value()) { // make new optional // on each call return optitype{ v_ }; } // else return nullopt; }; // users have all three // any_, optional holding the value // and the value return make_pair(lambada_, any_); } // any_opt #pragma endregion } // dbj /* inclusion of this file defines the kind of a licence used */ #include "../dbj_license.h"
28.038462
81
0.676543
d29a4165bec4ab2139f14b8d28962f4fcdc1fa71
4,455
h
C
src/amuse/community/seba/src/include/star/main_sequence.h
rknop/amuse
85d5bdcc29cfc87dc69d91c264101fafd6658aec
[ "Apache-2.0" ]
1
2019-04-09T09:06:08.000Z
2019-04-09T09:06:08.000Z
src/amuse/community/seba/src/include/star/main_sequence.h
rknop/amuse
85d5bdcc29cfc87dc69d91c264101fafd6658aec
[ "Apache-2.0" ]
2
2018-06-22T13:02:14.000Z
2018-09-06T20:08:43.000Z
src/amuse/community/seba/src/include/star/main_sequence.h
rknop/amuse
85d5bdcc29cfc87dc69d91c264101fafd6658aec
[ "Apache-2.0" ]
2
2021-11-19T04:41:37.000Z
2021-11-20T02:11:17.000Z
/* * main_sequence.h: derived class for evolution of stars in the * core-hydrogen burning stage. * *..................................................................... * version 1: Jan 1994 Simon F. Portegies Zwart * version 2: *................................................................... * This file includes: * 1) definition of class main_sequence * *.................................................................... */ #ifndef _MAIN_SEQUENCE # define _MAIN_SEQUENCE #include "single_star.h" //#include "proto_star.h" #include "brown_dwarf.h" #include "hyper_giant.h" #include "hertzsprung_gap.h" #include "thorne_zytkow.h" #include "helium_star.h" // Known class declarations. class proto_star; /*----------------------------------------------------------------------------- * main_sequence -- a derived class for element evolution. *----------------------------------------------------------------------------- */ class main_sequence : public single_star { private: real main_sequence_core_mass(); real main_sequence_core_radius(); void adjust_donor_age(const real mdot); public : main_sequence(node* n) : single_star(n) {} main_sequence(proto_star& p); ~main_sequence() {} stellar_type get_element_type() {return Main_Sequence;} bool remnant() {return false;} bool magnetic() { return (get_total_mass()<= cnsts.parameters(maximum_magnetic_mass_limit) && get_total_mass()>= cnsts.parameters(minimum_magnetic_mass_limit))?true:false; } void adjust_next_update_age(); real nucleair_evolution_timescale(); void instantaneous_element(); void evolve_element(const real); real bolometric_correction(); void detect_spectral_features(); void update_wind_constant(); void update(); real final_core_mass(); // Mass transfer utilities. star* subtrac_mass_from_donor(const real, real&); star* reduce_mass(const real); void adjust_accretor_age(const real mdot, const bool rejuvenate); void adjust_age_after_mass_loss(const real mdot, const bool rejuvenate); real add_mass_to_accretor(real, bool, const real = -1.); // Mass transfer stability real zeta_adiabatic(); real zeta_thermal(); real gyration_radius_sq(); real convective_envelope_mass(); real convective_envelope_radius(); // Spiral in and common envelope. star* merge_elements(star*); // Friend functions. friend brown_dwarf::brown_dwarf(main_sequence &); friend hertzsprung_gap::hertzsprung_gap(main_sequence &); friend sub_giant::sub_giant(main_sequence &); friend horizontal_branch::horizontal_branch(main_sequence &); friend thorne_zytkow::thorne_zytkow(main_sequence &); //friend helium_star::helium_star(main_sequence &); real get_evolve_timestep(); real base_main_sequence_luminosity(const real mass, const real z); real base_main_sequence_luminosity(const real z); real main_sequence_luminosity(const real time, const real mass, const real z); real main_sequence_radius(const real time, const real mass, const real z); real zams_luminosity_correction(const real time, const real mass, const real z); real zams_radius_correction(const real time, const real mass, const real z); real alpha_l_coefficient(const real mass, const real z); real beta_l_coefficient(const real mass, const real z); real alpha_r_coefficient(const real mass, const real z); real beta_r_coefficient(const real mass, const real z); real gamma_r_coefficient(const real mass, const real z); //+++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++ // Replaces old equations // friend single_star::main_sequence_hook_mass(const real z); }; #endif // _MAIN_SEQUENCE
32.518248
80
0.549944
3019e1e7b2e34d08a56dff8c29ded30725f96349
8,376
c
C
libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/pdb/fsl_pdb_hal.c
oliviermartin/mbed
2f63fa7d78a264b26ea626d542ae1b19e239bb6a
[ "Apache-2.0" ]
54
2015-12-21T13:07:43.000Z
2019-04-16T20:06:25.000Z
libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/pdb/fsl_pdb_hal.c
oliviermartin/mbed
2f63fa7d78a264b26ea626d542ae1b19e239bb6a
[ "Apache-2.0" ]
10
2015-10-31T15:16:14.000Z
2019-03-12T13:25:29.000Z
libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/pdb/fsl_pdb_hal.c
oliviermartin/mbed
2f63fa7d78a264b26ea626d542ae1b19e239bb6a
[ "Apache-2.0" ]
30
2015-12-27T21:44:56.000Z
2019-03-26T07:13:26.000Z
/* * Copyright (c) 2014, Freescale Semiconductor, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, this list * of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * o Neither the name of Freescale Semiconductor, Inc. nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "fsl_pdb_hal.h" /*FUNCTION********************************************************************* * * Function Name : PDB_HAL_Init * Description : Reset PDB's registers to a known state. This state is * defined in Reference Manual, which is power on reset value. * *END*************************************************************************/ void PDB_HAL_Init(uint32_t baseAddr) { uint32_t chn, preChn; HW_PDB_SC_WR(baseAddr, 0U); HW_PDB_MOD_WR(baseAddr, 0xFFFFU); HW_PDB_IDLY_WR(baseAddr, 0xFFFFU); /* For ADC trigger. */ for (chn = 0U; chn < HW_PDB_CHnC1_COUNT; chn++) { HW_PDB_CHnC1_WR(baseAddr, chn, 0U); HW_PDB_CHnS_WR(baseAddr, chn,0xFU); for (preChn = 0U; preChn < FSL_FEATURE_PDB_ADC_PRE_CHANNEL_COUNT; preChn++) { PDB_HAL_SetPreTriggerDelayCount(baseAddr, chn, preChn, 0U); } } /* For DAC trigger. */ for (chn = 0U; chn < HW_PDB_DACINTCn_COUNT; chn++) { HW_PDB_DACINTCn_WR(baseAddr, chn, 0U); HW_PDB_DACINTn_WR(baseAddr ,chn, 0U); } /* For Pulse out trigger. */ HW_PDB_POEN_WR(baseAddr, 0U); for (chn = 0U; chn < HW_PDB_POnDLY_COUNT; chn++) { HW_PDB_POnDLY_WR(baseAddr, chn, 0U); } /* Load the setting value. */ PDB_HAL_Enable(baseAddr); PDB_HAL_SetLoadRegsCmd(baseAddr); PDB_HAL_Disable(baseAddr); } /*FUNCTION********************************************************************* * * Function Name : PDB_HAL_SetPreTriggerBackToBackCmd * Description : Switch to enable pre-trigger's back to back mode. * *END*************************************************************************/ void PDB_HAL_SetPreTriggerBackToBackCmd(uint32_t baseAddr, uint32_t chn, uint32_t preChn, bool enable) { assert(chn < HW_PDB_CHnC1_COUNT); assert(preChn < FSL_FEATURE_PDB_ADC_PRE_CHANNEL_COUNT); uint32_t tmp32 = HW_PDB_CHnC1_RD(baseAddr, chn); if (enable) { tmp32 |= (1U << (preChn + BP_PDB_CHnC1_BB)); } else { tmp32 &= ~(1U << (preChn + BP_PDB_CHnC1_BB)); } HW_PDB_CHnC1_WR(baseAddr, chn, tmp32); } /*FUNCTION********************************************************************* * * Function Name : PDB_HAL_SetPreTriggerOutputCmd * Description : Switch to enable pre-trigger's output. * *END*************************************************************************/ void PDB_HAL_SetPreTriggerOutputCmd(uint32_t baseAddr, uint32_t chn, uint32_t preChn, bool enable) { assert(chn < HW_PDB_CHnC1_COUNT); assert(preChn < FSL_FEATURE_PDB_ADC_PRE_CHANNEL_COUNT); uint32_t tmp32 = HW_PDB_CHnC1_RD(baseAddr, chn); if (enable) { tmp32 |= (1U << (preChn + BP_PDB_CHnC1_TOS)); } else { tmp32 &= ~(1U << (preChn + BP_PDB_CHnC1_TOS)); } HW_PDB_CHnC1_WR(baseAddr, chn, tmp32); } /*FUNCTION********************************************************************* * * Function Name : PDB_HAL_SetPreTriggerCmd * Description : Switch to enable pre-trigger's. * *END*************************************************************************/ void PDB_HAL_SetPreTriggerCmd(uint32_t baseAddr, uint32_t chn, uint32_t preChn, bool enable) { assert(chn < HW_PDB_CHnC1_COUNT); assert(preChn < FSL_FEATURE_PDB_ADC_PRE_CHANNEL_COUNT); uint32_t tmp32 = HW_PDB_CHnC1_RD(baseAddr, chn); if (enable) { tmp32 |= (1U << (preChn + BP_PDB_CHnC1_EN)); } else { tmp32 &= ~(1U << (preChn + BP_PDB_CHnC1_EN)); } HW_PDB_CHnC1_WR(baseAddr, chn, tmp32); } /*FUNCTION********************************************************************* * * Function Name : PDB_HAL_ClearPreTriggerFlag * Description : Clear the flag that the PDB counter reaches to the * pre-trigger's delay value. * *END*************************************************************************/ void PDB_HAL_ClearPreTriggerFlag(uint32_t baseAddr, uint32_t chn, uint32_t preChn) { assert(chn < HW_PDB_CHnS_COUNT); assert(preChn < FSL_FEATURE_PDB_ADC_PRE_CHANNEL_COUNT); /* Write 0 to clear. */ uint32_t tmp32 = HW_PDB_CHnS_RD(baseAddr, chn); /* Get current value. */ tmp32 &= ~(1U << (preChn + BP_PDB_CHnS_CF)); /* Update the change. */ tmp32 &= BM_PDB_CHnS_CF; /* Limit the change range. */ HW_PDB_CHnS_WR(baseAddr, chn, tmp32); } /*FUNCTION********************************************************************* * * Function Name : PDB_HAL_ClearPreTriggerSeqErrFlag * Description : Clear the flag that sequence error is detected. * *END*************************************************************************/ void PDB_HAL_ClearPreTriggerSeqErrFlag(uint32_t baseAddr, uint32_t chn, uint32_t preChn) { assert(chn < HW_PDB_CHnS_COUNT); assert(preChn < FSL_FEATURE_PDB_ADC_PRE_CHANNEL_COUNT); /* Write 1 to clear. */ uint32_t tmp32 = HW_PDB_CHnS_RD(baseAddr, chn); /* Get current value. */ tmp32 &= ~BM_PDB_CHnS_ERR;/* Clear the operate controller. */ tmp32 |= ( 1U << (preChn + BP_PDB_CHnS_ERR) );/* Add indicated clear operator. */ HW_PDB_CHnS_WR(baseAddr, chn, tmp32); } /*FUNCTION********************************************************************* * * Function Name : PDB_HAL_SetPreTriggerDelayCount * Description : Set the delay value for pre-trigger. * *END*************************************************************************/ void PDB_HAL_SetPreTriggerDelayCount(uint32_t baseAddr, uint32_t chn, uint32_t preChn, uint32_t value) { assert(chn < HW_PDB_CHnDLY0_COUNT); assert(preChn < FSL_FEATURE_PDB_ADC_PRE_CHANNEL_COUNT); switch (preChn) { case 0U: BW_PDB_CHnDLY0_DLY(baseAddr, chn, value); break; #if (FSL_FEATURE_PDB_ADC_PRE_CHANNEL_COUNT > 1U) case 1U: BW_PDB_CHnDLY1_DLY(baseAddr, chn, value); break; #endif /* FSL_FEATURE_PDB_ADC_PRE_CHANNEL_COUNT */ default: break; } } /*FUNCTION********************************************************************* * * Function Name : PDB_HAL_SetPulseOutCmd * Description : Switch to enable the pulse-out trigger. * *END*************************************************************************/ void PDB_HAL_SetPulseOutCmd(uint32_t baseAddr, uint32_t pulseChn, bool enable) { assert(pulseChn < HW_PDB_POnDLY_COUNT); uint32_t tmp32 = HW_PDB_POEN_RD(baseAddr); if (enable) { tmp32 |= (1U << (pulseChn+BP_PDB_POEN_POEN)); } else { tmp32 &= ~(1U << (pulseChn+BP_PDB_POEN_POEN)); } HW_PDB_POEN_WR(baseAddr, tmp32); } /****************************************************************************** * EOF *****************************************************************************/
35.948498
102
0.585244
3040eff52e58849f1a7815610dc4fdf765edc2a1
7,104
h
C
include/openspace/util/openspacemodule.h
scivis-exhibitions/OpenSpace
5b69cf45f110354ecf3bdbcee8cf9d2c75b07e9e
[ "MIT" ]
489
2015-07-14T22:23:10.000Z
2022-03-30T07:59:47.000Z
include/openspace/util/openspacemodule.h
scivis-exhibitions/OpenSpace
5b69cf45f110354ecf3bdbcee8cf9d2c75b07e9e
[ "MIT" ]
1,575
2016-07-12T18:10:22.000Z
2022-03-31T20:12:55.000Z
include/openspace/util/openspacemodule.h
scivis-exhibitions/OpenSpace
5b69cf45f110354ecf3bdbcee8cf9d2c75b07e9e
[ "MIT" ]
101
2016-03-01T02:22:01.000Z
2022-02-25T15:36:27.000Z
/***************************************************************************************** * * * OpenSpace * * * * Copyright (c) 2014-2021 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * * without restriction, including without limitation the rights to use, copy, modify, * * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * * permit persons to whom the Software is furnished to do so, subject to the following * * conditions: * * * * The above copyright notice and this permission notice shall be included in all copies * * or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ #ifndef __OPENSPACE_CORE___OPENSPACEMODULE___H__ #define __OPENSPACE_CORE___OPENSPACEMODULE___H__ #include <openspace/properties/propertyowner.h> #include <ghoul/systemcapabilities/version.h> #include <string> #include <vector> namespace ghoul { class Dictionary; } namespace openspace { namespace documentation { struct Documentation; } namespace scripting { struct LuaLibrary; } class ModuleEngine; /** * This class is the base class for an OpenSpace module. A module groups functionality * into a useful granularity to be mostly used self-sufficiently. Each OpenSpaceModule * needs a unique, nonempty <code>name</code>. */ class OpenSpaceModule : public properties::PropertyOwner { public: /** * Constructs the OpenSpaceModule with a specific \p name. The uniqueness of the * \p name will be checked at a later stage. * * \param name The name of this OpenSpace module * * \pre \p name must not be empty */ OpenSpaceModule(std::string name); /// Default destructor virtual ~OpenSpaceModule() = default; /** * Initialization method that will register a token of the form * <code>${MODULE_\<\<NAME\>\>}</code> for a specific <code>\<\<NAME\>\></code> that * is set in the OpenSpaceModule constructor. This method will call the * internalInitialize method for further customization for each subclass. */ void initialize(const ghoul::Dictionary& configuration); /** * This method calls the internalInitializeGL method for further customization for * each subclass. */ void initializeGL(); /** * Empty deinitialization method that will call the internalDeinitialize method for * module-specific customization. */ void deinitialize(); /** * This method will call the internalDeinitializeGL method for each subclass. */ void deinitializeGL(); /** * Returns a list of Documentation classes that are valid for this OpenSpaceModule. * * \return A list of Documentation classes that are valid for this OpenSapceModule */ virtual std::vector<documentation::Documentation> documentations() const; /** * Returns the Lua library with functions defined by this OpenSpaceModule. The default * implementation returns an empty library. * * \return The Lua library with functions defined by this OpenSpaceModule */ virtual scripting::LuaLibrary luaLibrary() const; /** * Returns the Lua libraries that are defined by objects contained in this * OpenSpaceModule. Note that the #luaLibrary library is *not* contained in this list * as this is solely the list of libraries as defined by, for example Renderables, * defined in the OpenSpaceModule. * * \return A list of libraries defined by items contained in this OpenSpaceModule */ virtual std::vector<scripting::LuaLibrary> luaLibraries() const; /** * Returns the minimum required OpenGL version of this OpenSpaceModule. Unless * overwritten, it returns an OpenGL version of <code>3.3</code>. * * \return The minimum required OpenGL version of this OpenSpaceModule */ virtual ghoul::systemcapabilities::Version requiredOpenGLVersion() const; /** * Returns the list of required OpenGL extensions for this OpenSpaceModule. Unless * overwritten, this function returns an empty list. * * \return The list of required OpenGL extensions necessary to use this * OpenSpaceModule */ virtual std::vector<std::string> requiredOpenGLExtensions() const; protected: /** * Customization point for each derived class. The internalInitialize method is called * by the initialize method. * * \param configuration The configuration options that were read from the * configuration file */ virtual void internalInitialize(const ghoul::Dictionary& configuration); /** * Customization point for each derived class. The internalInitializeGL method is * called by the initializeGL method at a time when a valid OpenGL state is * guaranteed. */ virtual void internalInitializeGL(); /** * Customization point for each derived class. The internalDeinitialize method is * called by the deinitialize method. */ virtual void internalDeinitialize(); /** * Customization point for each derived class. The internalDeinitializeGL method is * called by the deinitializeGL method at a time when a valid OpenGL state is * guaranteed. */ virtual void internalDeinitializeGL(); /** * Returns the path for this module, possibly containing ghoul::filesystem::FileSystem * path tokens. */ std::string modulePath() const; /** * Returns a const pointer to the module engine */ const ModuleEngine* moduleEngine() const; }; } // namespace openspace #endif // __OPENSPACE_CORE___OPENSPACEMODULE___H__
40.594286
90
0.613316
308eaac0ce3435aa39fbd54addf19dbf6a31892e
232
h
C
Demo/TestSection/THKExpandLabel/THKExpandLabelViewController.h
chengzongxin/Demo
504d1d78b15970b4232d7f0cb1b95c3568ac6c23
[ "MIT" ]
null
null
null
Demo/TestSection/THKExpandLabel/THKExpandLabelViewController.h
chengzongxin/Demo
504d1d78b15970b4232d7f0cb1b95c3568ac6c23
[ "MIT" ]
null
null
null
Demo/TestSection/THKExpandLabel/THKExpandLabelViewController.h
chengzongxin/Demo
504d1d78b15970b4232d7f0cb1b95c3568ac6c23
[ "MIT" ]
null
null
null
// // THKExpandLabelViewController.h // Demo // // Created by Joe.cheng on 2021/12/27. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface THKExpandLabelViewController : UIViewController @end NS_ASSUME_NONNULL_END
13.647059
58
0.762931
fddd3375cb1b57ebb098c501638dd1859f9ea080
8,580
h
C
gdal/ogr/ogrsf_frmts/gpx/ogr_gpx.h
jpapadakis/gdal
f07aa15fd65af36b04291303cc6834c87f662814
[ "MIT" ]
3,100
2015-01-02T10:33:40.000Z
2022-03-31T02:06:51.000Z
gdal/ogr/ogrsf_frmts/gpx/ogr_gpx.h
jpapadakis/gdal
f07aa15fd65af36b04291303cc6834c87f662814
[ "MIT" ]
3,496
2015-01-06T16:53:30.000Z
2022-03-31T20:18:51.000Z
gdal/ogr/ogrsf_frmts/gpx/ogr_gpx.h
jpapadakis/gdal
f07aa15fd65af36b04291303cc6834c87f662814
[ "MIT" ]
2,036
2015-01-08T20:22:12.000Z
2022-03-31T10:24:08.000Z
/****************************************************************************** * $Id$ * * Project: GPX Translator * Purpose: Definition of classes for OGR .gpx driver. * Author: Even Rouault, even dot rouault at spatialys.com * ****************************************************************************** * Copyright (c) 2007-2010, Even Rouault <even dot rouault at spatialys.com> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef OGR_GPX_H_INCLUDED #define OGR_GPX_H_INCLUDED #include "ogrsf_frmts.h" #ifdef HAVE_EXPAT #include "ogr_expat.h" #endif class OGRGPXDataSource; typedef enum { GPX_NONE, GPX_WPT, GPX_TRACK, GPX_ROUTE, GPX_ROUTE_POINT, GPX_TRACK_POINT, } GPXGeometryType; /************************************************************************/ /* OGRGPXLayer */ /************************************************************************/ class OGRGPXLayer final: public OGRLayer { OGRFeatureDefn* poFeatureDefn; OGRSpatialReference *poSRS; OGRGPXDataSource* poDS; GPXGeometryType gpxGeomType; int nGPXFields; bool bWriteMode; int nNextFID; VSILFILE* fpGPX; /* Large file API */ #ifdef HAVE_EXPAT XML_Parser oParser; XML_Parser oSchemaParser; #endif bool inInterestingElement; bool hasFoundLat; bool hasFoundLon; #ifdef HAVE_EXPAT double latVal; double lonVal; #endif char* pszSubElementName; char* pszSubElementValue; int nSubElementValueLen; #ifdef HAVE_EXPAT int iCurrentField; #endif OGRFeature* poFeature; OGRFeature ** ppoFeatureTab; int nFeatureTabLength; int nFeatureTabIndex; OGRMultiLineString* multiLineString; OGRLineString* lineString; int depthLevel; int interestingDepthLevel; #ifdef HAVE_EXPAT OGRFieldDefn* currentFieldDefn; bool inExtensions; int extensionsDepthLevel; bool inLink; int iCountLink; #endif int nMaxLinks; bool bEleAs25D; int trkFID; int trkSegId; int trkSegPtId; int rteFID; int rtePtId; #ifdef HAVE_EXPAT bool bStopParsing; int nWithoutEventCounter; int nDataHandlerCounter; #endif int iFirstGPXField; private: void WriteFeatureAttributes( OGRFeature *poFeature, int nIdentLevel = 1 ); void LoadExtensionsSchema(); #ifdef HAVE_EXPAT void AddStrToSubElementValue(const char* pszStr); #endif bool OGRGPX_WriteXMLExtension(const char* pszTagName, const char* pszContent); public: OGRGPXLayer(const char *pszFilename, const char* layerName, GPXGeometryType gpxGeomType, OGRGPXDataSource* poDS, int bWriteMode = FALSE); ~OGRGPXLayer(); void ResetReading() override; OGRFeature * GetNextFeature() override; OGRErr ICreateFeature( OGRFeature *poFeature ) override; OGRErr CreateField( OGRFieldDefn *poField, int bApproxOK ) override; OGRFeatureDefn * GetLayerDefn() override { return poFeatureDefn; } int TestCapability( const char * ) override; #ifdef HAVE_EXPAT void startElementCbk(const char *pszName, const char **ppszAttr); void endElementCbk(const char *pszName); void dataHandlerCbk(const char *data, int nLen); void startElementLoadSchemaCbk(const char *pszName, const char **ppszAttr); void endElementLoadSchemaCbk(const char *pszName); void dataHandlerLoadSchemaCbk(const char *data, int nLen); #endif static OGRErr CheckAndFixCoordinatesValidity( double* pdfLatitude, double* pdfLongitude ); }; /************************************************************************/ /* OGRGPXDataSource */ /************************************************************************/ typedef enum { GPX_VALIDITY_UNKNOWN, GPX_VALIDITY_INVALID, GPX_VALIDITY_VALID } OGRGPXValidity; class OGRGPXDataSource final: public OGRDataSource { char* pszName; OGRGPXLayer** papoLayers; int nLayers; /* Export related */ VSILFILE *fpOutput; /* Large file API */ bool bIsBackSeekable; const char *pszEOL; int nOffsetBounds; double dfMinLat; double dfMinLon; double dfMaxLat; double dfMaxLon; GPXGeometryType lastGPXGeomTypeWritten; bool bUseExtensions; char* pszExtensionsNS; #ifdef HAVE_EXPAT OGRGPXValidity validity; int nElementsRead; char* pszVersion; XML_Parser oCurrentParser; int nDataHandlerCounter; #endif public: OGRGPXDataSource(); ~OGRGPXDataSource(); int nLastRteId; int nLastTrkId; int nLastTrkSegId; int Open( const char * pszFilename, int bUpdate ); int Create( const char *pszFilename, char **papszOptions ); const char* GetName() override { return pszName; } int GetLayerCount() override { return nLayers; } OGRLayer* GetLayer( int ) override; OGRLayer * ICreateLayer( const char * pszLayerName, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ) override; int TestCapability( const char * ) override; VSILFILE * GetOutputFP() { return fpOutput; } void SetLastGPXGeomTypeWritten(GPXGeometryType gpxGeomType) { lastGPXGeomTypeWritten = gpxGeomType; } GPXGeometryType GetLastGPXGeomTypeWritten() { return lastGPXGeomTypeWritten; } int GetUseExtensions() { return bUseExtensions; } const char* GetExtensionsNS() { return pszExtensionsNS; } #ifdef HAVE_EXPAT void startElementValidateCbk(const char *pszName, const char **ppszAttr); void dataHandlerValidateCbk(const char *data, int nLen); const char* GetVersion() { return pszVersion; } #endif void AddCoord(double dfLon, double dfLat); void PrintLine(const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (2, 3); }; #endif /* ndef OGR_GPX_H_INCLUDED */
34.183267
100
0.5331
6553eaaff1b7c40591c6d432672b439e0d3f4983
30,737
h
C
common/value.h
RobotLocomotion/drake-python3.7
ae397a4c6985262d23e9675b9bf3927c08d027f5
[ "BSD-3-Clause" ]
2
2021-02-25T02:01:02.000Z
2021-03-17T04:52:04.000Z
common/value.h
RobotLocomotion/drake-python3.7
ae397a4c6985262d23e9675b9bf3927c08d027f5
[ "BSD-3-Clause" ]
null
null
null
common/value.h
RobotLocomotion/drake-python3.7
ae397a4c6985262d23e9675b9bf3927c08d027f5
[ "BSD-3-Clause" ]
1
2021-06-13T12:05:39.000Z
2021-06-13T12:05:39.000Z
#pragma once #include <memory> #include <stdexcept> #include <string> #include <type_traits> #include <typeinfo> #include <utility> #include "drake/common/copyable_unique_ptr.h" #include "drake/common/drake_copyable.h" #include "drake/common/hash.h" #include "drake/common/is_cloneable.h" #include "drake/common/nice_type_name.h" namespace drake { #if !defined(DRAKE_DOXYGEN_CXX) template <typename T> class Value; namespace internal { // A traits type for Value<T>, where use_copy is true when T's copy constructor // and copy-assignment operator are used and false when T's Clone is used. template <typename T, bool use_copy> struct ValueTraitsImpl {}; template <typename T> using ValueTraits = ValueTraitsImpl<T, std::is_copy_constructible<T>::value>; // SFINAE type for whether Value<T>(Arg1, Args...) should be a forwarding ctor. // In our ctor overload that copies into the storage, choose_copy == true. template <bool choose_copy, typename T, typename Arg1, typename... Args> using ValueForwardingCtorEnabled = typename std::enable_if_t< // There must be such a constructor. std::is_constructible<T, Arg1, Args...>::value && // Disable this ctor when given T directly; in that case, we // should call our Value(const T&) ctor above, not try to copy- // construct a T(const T&). !std::is_same<T, Arg1>::value && !std::is_same<T&, Arg1>::value && // Only allow real ctors, not POD "constructor"s. !std::is_fundamental<T>::value && // Disambiguate our copy implementation from our clone implementation. (choose_copy == std::is_copy_constructible<T>::value)>; template <typename T> using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>; } // namespace internal #endif /// A fully type-erased container class. An AbstractValue stores an object of /// some type T (where T is declared during at construction time) that at /// runtime can be passed between functions without mentioning T. Only when /// the stored T must be accessed does the user need to mention T again. /// /// (Advanced.) Note that AbstractValue's getters and setters method declare /// that "If T does not match, a std::logic_error will be thrown with a helpful /// error message". The code that implements this check uses hashing, so in /// the extraordinarily unlikely case of a 64-bit hash collision, the error may /// go undetected in Release builds. (Debug builds have extra checks that will /// trigger.) /// /// (Advanced.) Only Value should inherit directly from AbstractValue. /// User-defined classes with additional features may inherit from Value. class AbstractValue { public: DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(AbstractValue) virtual ~AbstractValue(); /// Returns an AbstractValue containing the given @p value. template <typename T> static std::unique_ptr<AbstractValue> Make(const T& value); /// Returns the value wrapped in this AbstractValue as a const reference. /// The reference remains valid only until this object is set or destroyed. /// @tparam T The originally declared type of this AbstractValue, e.g., from /// AbstractValue::Make<T>() or Value<T>::Value(). If T does not match, a /// std::logic_error will be thrown with a helpful error message. template <typename T> const T& get_value() const { return cast<T>().get_value(); } /// Returns the value wrapped in this AbstractValue as mutable reference. /// The reference remains valid only until this object is set or destroyed. /// @tparam T The originally declared type of this AbstractValue, e.g., from /// AbstractValue::Make<T>() or Value<T>::Value(). If T does not match, a /// std::logic_error will be thrown with a helpful error message. template <typename T> T& get_mutable_value() { return cast<T>().get_mutable_value(); } /// Sets the value wrapped in this AbstractValue. /// @tparam T The originally declared type of this AbstractValue, e.g., from /// AbstractValue::Make<T>() or Value<T>::Value(). If T does not match, a /// std::logic_error will be thrown with a helpful error message. template <typename T> void set_value(const T& v) { cast<T>().set_value(v); } /// Returns the value wrapped in this AbstractValue, if T matches the /// originally declared type of this AbstractValue. /// @tparam T The originally declared type of this AbstractValue, e.g., from /// AbstractValue::Make<T>() or Value<T>::Value(). If T does not match, /// returns nullptr. template <typename T> const T* maybe_get_value() const; /// Returns a copy of this AbstractValue. virtual std::unique_ptr<AbstractValue> Clone() const = 0; /// Copies the value in @p other to this value. If other is not compatible /// with this object, a std::logic_error will be thrown with a helpful error /// message. virtual void SetFrom(const AbstractValue& other) = 0; /// Returns typeid of the contained object of type T. If T is polymorphic, /// this returns the typeid of the most-derived type of the contained object. virtual const std::type_info& type_info() const = 0; /// Returns typeid(T) for this Value<T> object. If T is polymorphic, this /// does NOT reflect the typeid of the most-derived type of the contained /// object; the result is always the base type T. virtual const std::type_info& static_type_info() const = 0; /// Returns a human-readable name for the underlying type T. This may be /// slow but is useful for error messages. If T is polymorphic, this returns /// the typeid of the most-derived type of the contained object. std::string GetNiceTypeName() const; protected: #if !defined(DRAKE_DOXYGEN_CXX) // Use a struct argument (instead of a bare size_t) so that no code // tries to convert a single-element numeric initializer_list to // a `const AbstractValue&`. (This works around a bug in GCC 5.) struct Wrap { size_t value{}; }; explicit AbstractValue(Wrap hash) : type_hash_(hash.value) {} #endif private: template <typename T> bool is_maybe_matched() const; template <typename T> const Value<T>& cast() const; template <typename T> Value<T>& cast(); template <typename T> [[noreturn]] void ThrowCastError() const; [[noreturn]] void ThrowCastError(const std::string&) const; // The TypeHash<T>::value supplied by the Value<T> constructor. const size_t type_hash_; }; /// A container class for an arbitrary type T (with some restrictions). This /// class inherits from AbstractValue and therefore at runtime can be passed /// between functions without mentioning T. /// /// Example: /// @code /// void print_string(const AbstractValue& arg) { /// const std::string& message = arg.get_value<std::string>(); /// std::cerr << message; /// } /// void meow() { /// const Value<std::string> value("meow"); /// print_string(value); /// } /// @endcode /// /// (Advanced.) User-defined classes with additional features may subclass /// Value, but should take care to override Clone(). /// /// @tparam T Must be copy-constructible or cloneable. Must not be a pointer, /// array, nor have const, volatile, or reference qualifiers. template <typename T> class Value : public AbstractValue { public: DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Value) static_assert( std::is_same_v<T, internal::remove_cvref_t<T>>, "T should not have const, volatile, or reference qualifiers."); static_assert( !std::is_pointer_v<T> && !std::is_array_v<T>, "T cannot be a pointer or array."); /// Constructs a Value<T> using T's default constructor, if available. /// This is only available for T's that support default construction. #if !defined(DRAKE_DOXYGEN_CXX) // T1 is template boilerplate; do not specify it at call sites. template <typename T1 = T, typename = typename std::enable_if_t< std::is_default_constructible<T1>::value>> #endif Value(); /// Constructs a Value<T> by copying or cloning the given value @p v. explicit Value(const T& v); /// Constructs a Value<T> by forwarding the given @p args to T's constructor, /// if available. This is only available for non-primitive T's that are /// constructible from @p args. #if defined(DRAKE_DOXYGEN_CXX) template <typename... Args> explicit Value(Args&&... args); #else // This overload is for copyable T. template <typename Arg1, typename... Args, typename = typename internal::ValueForwardingCtorEnabled<true, T, Arg1, Args...>> explicit Value(Arg1&& arg1, Args&&... args); // This overload is for cloneable T. template <typename Arg1, typename... Args, typename = void, typename = typename internal::ValueForwardingCtorEnabled<false, T, Arg1, Args...>> explicit Value(Arg1&& arg1, Args&&... args); #endif /// Constructs a Value<T> by copying or moving the given value @p v. /// @pre v is non-null. explicit Value(std::unique_ptr<T> v); ~Value() override {} /// Returns a const reference to the stored value. /// The reference remains valid only until this object is set or destroyed. const T& get_value() const; /// Returns a mutable reference to the stored value. /// The reference remains valid only until this object is set or destroyed. T& get_mutable_value(); /// Replaces the stored value with a new one. void set_value(const T& v); // AbstractValue overrides. std::unique_ptr<AbstractValue> Clone() const override; void SetFrom(const AbstractValue& other) override; const std::type_info& type_info() const final; const std::type_info& static_type_info() const final; // A using-declaration adds these methods into our class's Doxygen. using AbstractValue::static_type_info; using AbstractValue::GetNiceTypeName; private: using Traits = internal::ValueTraits<T>; typename Traits::Storage value_; }; #if !defined(DRAKE_DOXYGEN_CXX) // Declare some private helper structs. namespace internal { // Extracts a hash of the type `T` in a __PRETTY_FUNCTION__ templated on T. // // For, e.g., TypeHash<int> the pretty_func string `pretty` looks like this: // GCC 7.3: "... calc() [with T = int; size_t K = 16; ..." // Clang 6.0: "... calc() [T = int]" // // We grab the characters for T's type (e.g., "int") and hash them using FNV1a. // https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function // // The value of @p which_argument chooses the which pretty template argument to // hash. (Only one argument at a time is ever hashed.) In the GCC example // above, which_argument of 0 hashes "int" and 1 hashes "16". // // If T is a template type like "std::vector<U>", we only hash "std::vector" // here. We stop when we reach a '<' because each template argument is hashed // separately below using parameter packs (see `TypeHasher<T<Args...>>`). This // avoids compiler bugs where __PRETTY_FUNCTION__ is fickle about the spelling // of "T = std::vector<U>" vs "T = std::vector<U, std::allocator<U>>", varying // it from one method to the next. Because we visit each base type in turn, we // hash "std::vector" then "U" then "std::allocator" then "U" and so it doesn't // matter exactly how templates end up being spelled in __PRETTY_FUNCTION__. // // When @p discard_nested is true, then stopping at '<' means our success-return // value will be true; if discard_nested is false then seeing any '<' is an // error. Thus, we can detect and fail-fast when our specializations for // template parameters fail to match. // // When @p discard_cast is true, we will omit a leading cast-expression after // the equals sign, e.g., when pretty looks like "... [with K = (MyEnum)0]". // If we see any other open-paren than this possibly-skipped cast, then our // success-return value will be false. Thus, we can detect and fail-fast when // our specializations for non-type template parameters fail to match, or when // T's like function pointer signatures appear. // // Note that the compiler is required to inform us at compile-time if there are // undefined operations in the below, such as running off the end of a string. // Therefore, so as long as this function compiles, we know that `pretty` had // at least something that looks like "T = ..." in it. // // Returns true on success / false on failure. constexpr bool hash_template_argument_from_pretty_func( const char* pretty, int which_argument, bool discard_nested, bool discard_cast, FNV1aHasher* result) { // Advance to the desired template argument. For example, if which_argument // is 0 and pretty == "... calc() [T = int]", then advance to the typename // after the "T = " so that the cursor `p` is pointing at the 'i' in "int". const char* p = pretty; for (int n = 0; n <= which_argument; ++n) { for (; (*p != '='); ++p) {} // Advance to the '=' that we want. ++p; // Advance to ' '. ++p; // Advance to the typename we want. } // For enums, GCC 7's pretty says "(MyEnum)0" not "MyEnum::kFoo". We'll strip // off the useless parenthetical. if (discard_cast && (*p == '(')) { for (; (*p != ')'); ++p) {} // Advance to the ')'. ++p; } // Hash the characters in the typename, ending either when the typename ends // (';' or ']') or maybe when the first template argument begins ('<'). while ((*p != ';') && (*p != ']')) { // Map Clang's spelling for the anonymous namespace to match GCC. Start by // searching for the clang spelling starting at `p` ... const char* const clang_spelling = "(anonymous namespace)"; const char* clang_iter = clang_spelling; const char* pretty_iter = p; for (; *clang_iter != 0 && *pretty_iter != 0; ++clang_iter, ++pretty_iter) { if (*clang_iter != *pretty_iter) { break; } } // ... and if we found the entire clang_spelling, emit gcc_spelling instead. if (*clang_iter == 0) { const char* const gcc_spelling = "{anonymous}"; for (const char* c = gcc_spelling; *c; ++c) { result->add_byte(*c); } p = pretty_iter; continue; } // GCC distinguishes between "<unnamed>" and "{anonymous}", while Clang does // not. Map "<unamed>" to "{anonymous}" for consistency and to avoid // confusion with nested types ("<>") below. const char* const unnamed_spelling = "<unnamed>"; const char* unnamed_iter = unnamed_spelling; pretty_iter = p; for (; *unnamed_iter != 0 && *pretty_iter != 0; ++unnamed_iter, ++pretty_iter) { if (*unnamed_iter != *pretty_iter) { break; } } if (*unnamed_iter == 0) { const char* const anonymous_spelling = "{anonymous}"; for (const char* c = anonymous_spelling; *c; ++c) { result->add_byte(*c); } p = pretty_iter; continue; } // If we find a nested type ("<>"), then either we expected it (in which // case we're done) or we didn't expect it (and something is wrong). if (*p == '<') { if (discard_nested) { break; } else { return false; } } // If the type has parens (such as a function pointer or std::function), // then we can't handle it. Adding support for function types involves not // only unpacking the return and argument types, but also adding support // for const / volatile / reference / etc.). if (*p == '(') { return false; } result->add_byte(*p); ++p; } return true; } // Akin to C++17 std::void_t<>. template <typename...> using typehasher_void_t = void; // Traits type to ask whether T::NonTypeTemplateParameter exists. template <typename T, typename U = void> struct TypeHasherHasNonTypeTemplateParameter { static constexpr bool value = false; }; template <typename T> struct TypeHasherHasNonTypeTemplateParameter< T, typehasher_void_t<typename T::NonTypeTemplateParameter>> { static constexpr bool value = true; }; // Provides a struct templated on T so that __PRETTY_FUNCTION__ will express T // at compile time. The calc() function feeds the string representation of T // to `result`. Returns true on success / false on failure. This base struct // handles non-templated values (e.g., int); in a specialization down below, we // handle template template T's. template <typename T, bool = TypeHasherHasNonTypeTemplateParameter<T>::value> struct TypeHasher { // Returns true on success / false on failure. static constexpr bool calc(FNV1aHasher* result) { // With discard_nested disabled here, the hasher will fail if it sees a // '<' in the typename. If that happens, it means that the parameter pack // specialization(s) below did not match as expected. const int which_argument = 0; const bool discard_nested = false; const bool discard_cast = false; return hash_template_argument_from_pretty_func( __PRETTY_FUNCTION__, which_argument, discard_nested, discard_cast, result); } }; // Provides a struct templated on Ts... with a calc() that hashes a sequence of // types (a template parameter pack). template <typename... Args> struct ParameterPackHasher {}; // Specializes for base case: an empty pack. template <> struct ParameterPackHasher<> { static constexpr bool calc(FNV1aHasher*) { return true; } }; // Specializes for inductive case: recurse using first + rest. template <typename A, typename... B> struct ParameterPackHasher<A, B...> { static constexpr bool calc(FNV1aHasher* result) { bool success = TypeHasher<A>::calc(result); if (sizeof...(B)) { // Add delimiter so that pair<cub,scone> and pair<cubs,cone> are distinct. result->add_byte(','); success = success && ParameterPackHasher<B...>::calc(result); } return success; } }; // Specializes TypeHasher for template types T so that we have the typename of // each template argument separately from T's outer type (as explained in the // overview above). template <template <typename...> class T, class... Args> struct TypeHasher<T<Args...>, false> { static constexpr bool calc(FNV1aHasher* result) { // First, hash just the "T" template template type, not the "<Args...>". const int which_argument = 0; const bool discard_nested = true; const bool discard_cast = false; bool success = hash_template_argument_from_pretty_func( __PRETTY_FUNCTION__, which_argument, discard_nested, discard_cast, result); // Then, hash the "<Args...>". Add delimiters so that parameter pack // nesting is correctly hashed. result->add_byte('<'); success = success && ParameterPackHasher<Args...>::calc(result); result->add_byte('>'); return success; } }; // Provides a struct templated on `Typename Konstant`, similar to TypeHasher<T> // but here the "Konstant"'s string is hashed, not a typename. template <typename T, T K> struct ValueHasher { static constexpr bool calc(FNV1aHasher* result) { const int which_argument = 1; const bool discard_nested = false; const bool discard_cast = true; return hash_template_argument_from_pretty_func( __PRETTY_FUNCTION__, which_argument, discard_nested, discard_cast, result); } }; // Specializes TypeHasher for a non-type template value so that we have the // value of the template argument separately from T's outer type (as explained // in the overview above). template <typename T> struct TypeHasher<T, true> { static constexpr bool calc(FNV1aHasher* result) { // First, hash just the "T" template template type, not the "<U u>". const int which_argument = 0; const bool discard_nested = true; const bool discard_cast = false; hash_template_argument_from_pretty_func( __PRETTY_FUNCTION__, which_argument, discard_nested, discard_cast, result); // Then, hash the "<U=u>". using U = typename T::NonTypeTemplateParameter::value_type; result->add_byte('<'); bool success = TypeHasher<U>::calc(result); result->add_byte('='); success = success && ValueHasher<U, T::NonTypeTemplateParameter::value>::calc(result); result->add_byte('>'); return success; } }; // Provides a struct templated on Ns... with a calc() that hashes a sequence of // ints (an int parameter pack). template <int... Ns> struct IntPackHasher {}; // Specializes for base case: an empty pack. template <> struct IntPackHasher<> { static constexpr bool calc(FNV1aHasher*) { return true; } }; // Specializes for inductive case: recurse using first + rest. template <int N, int... Ns> struct IntPackHasher<N, Ns...> { static constexpr bool calc(FNV1aHasher* result) { result->add_byte('i'); result->add_byte('n'); result->add_byte('t'); result->add_byte('='); bool success = ValueHasher<int, N>::calc(result); if (sizeof...(Ns)) { result->add_byte(','); success = success && IntPackHasher<Ns...>::calc(result); } return success; } }; // Specializes TypeHasher for Eigen-like types. template <template <typename, int, int...> class T, typename U, int N, int... Ns> struct TypeHasher<T<U, N, Ns...>, false> { static constexpr bool calc(FNV1aHasher* result) { // First, hash just the "T" template template type, not the "<U, N, Ns...>". const int which_argument = 0; const bool discard_nested = true; const bool discard_cast = false; bool success = hash_template_argument_from_pretty_func( __PRETTY_FUNCTION__, which_argument, discard_nested, discard_cast, result); // Then, hash the "<U, N, Ns...>". Add delimiters so that parameter pack // nesting is correctly hashed. result->add_byte('<'); success = success && TypeHasher<U>::calc(result); result->add_byte(','); success = success && IntPackHasher<N, Ns...>::calc(result); result->add_byte('>'); return success; } }; // Computes a typename hash as a compile-time constant. By putting it into a // static constexpr, we force the compiler to compute the hash at compile time. // // We use these compile-time hashes to improve the performance of the downcast // checks in AbstractValue. The hash constant ends up being inlined into the // object code of AbstractValue's accessors. (We cannot use `typeid(T).name()` // for this purpose at compile-time, because it's not constexpr.) // // This implementation is intended to work for the kinds of `T`s we would see // in a `Value<T>`; notably, it does not support `T`s of type `std::function`, // function pointers, and the like. It also does not support `T`'s with // non-type template parameters. Unsupported types yield a hash value of zero // so that using-code can decide how to handle the failure. template <typename T> struct TypeHash { static constexpr size_t calc() { FNV1aHasher hasher; const bool success = TypeHasher<T>::calc(&hasher); const size_t hash = size_t(hasher); const size_t nonzero_hash = hash ? hash : 1; return success ? nonzero_hash : 0; } // The hash of "T", or zero when the type is not supported by the hasher. // (Such failures are expected to be rare.) static constexpr size_t value = calc(); }; // This is called once per process per T whose type_hash is 0. It logs a // TypeHash failure message to Drake's text log. int ReportZeroHash(const std::type_info& detail); // Any code in this file that uses TypeHash::value calls us for its T. template <typename T, size_t hash> struct ReportUseOfTypeHash { static void used() { // By default, do nothing. } }; template <typename T> struct ReportUseOfTypeHash<T, 0> { static void used() { static int dummy = ReportZeroHash(typeid(T)); (void)(dummy); } }; // For copyable types, we can store a T directly within Value<T> and we don't // need any special tricks to create or retrieve it. template <typename T> struct ValueTraitsImpl<T, true> { using Storage = T; static void reinitialize_if_necessary(Storage*) {} static const T& to_storage(const T& other) { return other; } static const Storage& to_storage(const std::unique_ptr<T>& other) { DRAKE_DEMAND(other.get() != nullptr); return *other; } static const T& access(const Storage& storage) { return storage; } // NOLINTNEXTLINE(runtime/references) static T& access(Storage& storage) { return storage; } }; // For non-copyable types, we store a copyable_unique_ptr<T> so that Value<T>'s // implementation's use of operator= and such work naturally. To store values, // we must Clone them; to access values, we must de-reference the pointer. template <typename T> struct ValueTraitsImpl<T, false> { static_assert( drake::is_cloneable<T>::value, "Types placed into a Value<T> must either be copyable or cloneable"); // We explicitly disallow Value<AbstractValue>. In cases where it occurs, it // is likely that someone has created functions such as // template DoBar(const AbstractValue& foo) { ... } // template <class Foo> DoBar(const Foo& foo) { DoBar(Value<Foo>{foo}); } // and accidentally called DoBar<AbstractValue>, or similar mistakes. static_assert(!std::is_same<T, std::remove_cv<AbstractValue>::type>::value, "T in Value<T> cannot be AbstractValue."); using Storage = typename drake::copyable_unique_ptr<T>; static void reinitialize_if_necessary(Storage* value) { *value = std::make_unique<T>(); } static Storage to_storage(const T& other) { return Storage{other.Clone()}; } static Storage to_storage(std::unique_ptr<T> other) { DRAKE_DEMAND(other.get() != nullptr); return Storage{std::move(other)}; } static const T& access(const Storage& storage) { return *storage; } // NOLINTNEXTLINE(runtime/references) static T& access(Storage& storage) { return *storage; } }; } // namespace internal template <typename T> std::unique_ptr<AbstractValue> AbstractValue::Make(const T& value) { return std::unique_ptr<AbstractValue>(new Value<T>(value)); } template <typename T> const T* AbstractValue::maybe_get_value() const { if (!is_maybe_matched<T>()) { return nullptr; } auto& self = static_cast<const Value<T>&>(*this); return &self.get_value(); } // In Debug mode, returns true iff `this` is-a `Value<T>`. In Release mode, a // false return means `this` is definitely not a `Value<T>`; true means `this` // is-probably-a `Value<T>`, but might rarely appear even for mismatched types. template <typename T> bool AbstractValue::is_maybe_matched() const { constexpr auto hash = internal::TypeHash<T>::value; internal::ReportUseOfTypeHash<T, hash>::used(); return (kDrakeAssertIsArmed || !hash) ? (typeid(T) == static_type_info()) : (hash == type_hash_); } // Casts this to a `const Value<T>&`, with error checking that throws. template <typename T> const Value<T>& AbstractValue::cast() const { if (!is_maybe_matched<T>()) { ThrowCastError<T>(); } return static_cast<const Value<T>&>(*this); } // Casts this to a `Value<T>&`, with error checking that throws. template <typename T> Value<T>& AbstractValue::cast() { if (!is_maybe_matched<T>()) { ThrowCastError<T>(); } return static_cast<Value<T>&>(*this); } // We use a separate method to report cast() errors so that cast() itself will // be inlined in Release builds. template <typename T> void AbstractValue::ThrowCastError() const { ThrowCastError(NiceTypeName::Get<T>()); } template <typename T> template <typename T1, typename T2> Value<T>::Value() : AbstractValue(Wrap{internal::TypeHash<T>::value}), value_{} { internal::ReportUseOfTypeHash<T, internal::TypeHash<T>::value>::used(); Traits::reinitialize_if_necessary(&value_); } template <typename T> Value<T>::Value(const T& v) : AbstractValue(Wrap{internal::TypeHash<T>::value}), value_(Traits::to_storage(v)) { internal::ReportUseOfTypeHash<T, internal::TypeHash<T>::value>::used(); } // We construct-in-place into our Storage value_. template <typename T> template <typename Arg1, typename... Args, typename> Value<T>::Value(Arg1&& arg1, Args&&... args) : AbstractValue(Wrap{internal::TypeHash<T>::value}), value_{std::forward<Arg1>(arg1), std::forward<Args>(args)...} { internal::ReportUseOfTypeHash<T, internal::TypeHash<T>::value>::used(); } // We move a unique_ptr into our Storage value_. template <typename T> template <typename Arg1, typename... Args, typename, typename> Value<T>::Value(Arg1&& arg1, Args&&... args) : AbstractValue(Wrap{internal::TypeHash<T>::value}), value_{std::make_unique<T>( std::forward<Arg1>(arg1), std::forward<Args>(args)...)} { internal::ReportUseOfTypeHash<T, internal::TypeHash<T>::value>::used(); } // An explanation of the this constructor: // // We start with a unique_ptr<T> v. We std::move it to get an xvalue // unique_ptr<T>&& that we pass to to_storage. // // In the copyable case, that matches to_storage(const unique_ptr<T>&), which // does a nonnull check and then returns an alias to the owned const T& within // v. Back in the Value constructor, the value_ member constructor is offered // const T& so it does T::T(const T&) copy construction. As the constructor // returns, the v argument goes out of scope and the T owned by v is deleted. // The users's unique_ptr<T> was transferred to Value<T> with a single copy. // // In the cloneable case, that matches to_storage(unique_ptr<T>), which means v // is moved into other. The to_storage does a nonnull check, then std::moves // other into an xvalue unique_ptr<T>&& again, then constructs a // copyable_unique_ptr<T> from the xvalue which moves the owned T resource into // that temporary, then returns the temporary by-value. By RVO, the return // value was already directly place into value_ and we are done. The user's // unique_ptr<T> was transferred to Value<T> without any Clone. template <typename T> Value<T>::Value(std::unique_ptr<T> v) : AbstractValue(Wrap{internal::TypeHash<T>::value}), value_{Traits::to_storage(std::move(v))} { internal::ReportUseOfTypeHash<T, internal::TypeHash<T>::value>::used(); } template <typename T> const T& Value<T>::get_value() const { return Traits::access(value_); } template <typename T> T& Value<T>::get_mutable_value() { return Traits::access(value_); } template <typename T> void Value<T>::set_value(const T& v) { value_ = Traits::to_storage(v); } template <typename T> std::unique_ptr<AbstractValue> Value<T>::Clone() const { return std::make_unique<Value<T>>(get_value()); } template <typename T> void Value<T>::SetFrom(const AbstractValue& other) { value_ = Traits::to_storage(other.get_value<T>()); } template <typename T> const std::type_info& Value<T>::type_info() const { return typeid(get_value()); } template <typename T> const std::type_info& Value<T>::static_type_info() const { return typeid(T); } #endif // DRAKE_DOXYGEN_CXX } // namespace drake
39.105598
80
0.694245
659165820d9dca4e002bed4f425d8f3629edb644
1,559
c
C
entry_winmain.c
jomael/win32_utf8
c784d1607d1dfdb21372c3e96c4d34ed86680322
[ "Unlicense" ]
91
2015-12-08T09:14:51.000Z
2022-03-02T11:34:04.000Z
entry_winmain.c
jomael/win32_utf8
c784d1607d1dfdb21372c3e96c4d34ed86680322
[ "Unlicense" ]
9
2017-01-10T16:42:54.000Z
2021-08-19T12:16:55.000Z
entry_winmain.c
jomael/win32_utf8
c784d1607d1dfdb21372c3e96c4d34ed86680322
[ "Unlicense" ]
9
2017-06-22T14:46:33.000Z
2021-03-17T22:20:06.000Z
/** * Win32 UTF-8 wrapper * * ---- * * WinMain() entry point. * Compile or #include this file as part of your sources if your program runs * in the graphical Windows subsystem and should not open a console window. */ #include "src/entry.h" int __stdcall wWinMain( // Avoid redefinition errors if wWinMain() was declared before, but don't // depend on it to keep compilation times low. #ifdef _WINBASE_ HINSTANCE hInstance, HINSTANCE hNull, LPWSTR lpCmdLine, #else void *hInstance, void *hNull, unsigned short *lpCmdLine, #endif int nCmdShow ) { (void)hInstance; (void)hNull; (void)lpCmdLine; (void)nCmdShow; return win32_utf8_entry(win32_utf8_main); } // If both WinMain() and wWinMain() are defined... // • Visual Studio (or more specifically, LINK.EXE) defaults to WinMain() // • Pelles C defaults to wWinMain(), without even printing a "ambiguous // entry point" warning // • MinGW/GCC doesn't care, and expects wWinMain() if you specify -municode // and -mwindows, and WinMain() if you only specify -mwindows. // Thus, we keep WinMain() as a convenience fallback for GCC. #ifndef _MSC_VER int __stdcall WinMain( // Avoid redefinition errors if WinMain() was declared before, but don't // depend on it to keep compilation times low. #ifdef _WINBASE_ HINSTANCE hInstance, HINSTANCE hNull, LPSTR lpCmdLine, #else void *hInstance, void *hNull, const char *lpCmdLine, #endif int nCmdShow ) { (void)hInstance; (void)hNull; (void)lpCmdLine; (void)nCmdShow; return win32_utf8_entry(win32_utf8_main); } #endif
22.926471
78
0.723541
45e0f05b77ae8653c264742c3c4c0251d2ae144b
2,720
h
C
message/generation/swift-mt-generation/repository/SR2018/parsers/SwiftMtParser_MT296Listener.h
Yanick-Salzmann/message-converter-c
6dfdf56e12f19e0f0b63ee0354fda16968f36415
[ "MIT" ]
null
null
null
message/generation/swift-mt-generation/repository/SR2018/parsers/SwiftMtParser_MT296Listener.h
Yanick-Salzmann/message-converter-c
6dfdf56e12f19e0f0b63ee0354fda16968f36415
[ "MIT" ]
null
null
null
message/generation/swift-mt-generation/repository/SR2018/parsers/SwiftMtParser_MT296Listener.h
Yanick-Salzmann/message-converter-c
6dfdf56e12f19e0f0b63ee0354fda16968f36415
[ "MIT" ]
null
null
null
#include "repository/ISwiftMtParser.h" #include "SwiftMtMessage.pb.h" #include <vector> #include <string> #include "BaseErrorListener.h" #include "SwiftMtParser_MT296Lexer.h" // Generated from C:/programming/message-converter-c/message/generation/swift-mt-generation/repository/SR2018/grammars/SwiftMtParser_MT296.g4 by ANTLR 4.7.2 #pragma once #include "antlr4-runtime.h" #include "SwiftMtParser_MT296Parser.h" namespace message::definition::swift::mt::parsers::sr2018 { /** * This interface defines an abstract listener for a parse tree produced by SwiftMtParser_MT296Parser. */ class SwiftMtParser_MT296Listener : public antlr4::tree::ParseTreeListener { public: virtual void enterMessage(SwiftMtParser_MT296Parser::MessageContext *ctx) = 0; virtual void exitMessage(SwiftMtParser_MT296Parser::MessageContext *ctx) = 0; virtual void enterBh(SwiftMtParser_MT296Parser::BhContext *ctx) = 0; virtual void exitBh(SwiftMtParser_MT296Parser::BhContext *ctx) = 0; virtual void enterBh_content(SwiftMtParser_MT296Parser::Bh_contentContext *ctx) = 0; virtual void exitBh_content(SwiftMtParser_MT296Parser::Bh_contentContext *ctx) = 0; virtual void enterAh(SwiftMtParser_MT296Parser::AhContext *ctx) = 0; virtual void exitAh(SwiftMtParser_MT296Parser::AhContext *ctx) = 0; virtual void enterAh_content(SwiftMtParser_MT296Parser::Ah_contentContext *ctx) = 0; virtual void exitAh_content(SwiftMtParser_MT296Parser::Ah_contentContext *ctx) = 0; virtual void enterUh(SwiftMtParser_MT296Parser::UhContext *ctx) = 0; virtual void exitUh(SwiftMtParser_MT296Parser::UhContext *ctx) = 0; virtual void enterTr(SwiftMtParser_MT296Parser::TrContext *ctx) = 0; virtual void exitTr(SwiftMtParser_MT296Parser::TrContext *ctx) = 0; virtual void enterSys_block(SwiftMtParser_MT296Parser::Sys_blockContext *ctx) = 0; virtual void exitSys_block(SwiftMtParser_MT296Parser::Sys_blockContext *ctx) = 0; virtual void enterSys_element(SwiftMtParser_MT296Parser::Sys_elementContext *ctx) = 0; virtual void exitSys_element(SwiftMtParser_MT296Parser::Sys_elementContext *ctx) = 0; virtual void enterSys_element_key(SwiftMtParser_MT296Parser::Sys_element_keyContext *ctx) = 0; virtual void exitSys_element_key(SwiftMtParser_MT296Parser::Sys_element_keyContext *ctx) = 0; virtual void enterSys_element_content(SwiftMtParser_MT296Parser::Sys_element_contentContext *ctx) = 0; virtual void exitSys_element_content(SwiftMtParser_MT296Parser::Sys_element_contentContext *ctx) = 0; virtual void enterMt(SwiftMtParser_MT296Parser::MtContext *ctx) = 0; virtual void exitMt(SwiftMtParser_MT296Parser::MtContext *ctx) = 0; }; } // namespace message::definition::swift::mt::parsers::sr2018
40.597015
156
0.802574
ca81ee73521a695cf19a7ae54fa457f29c288717
3,068
c
C
u-boot-1.1.6/cpu/mpc85xx/speed.c
XIANG07/u-boot-zjxiang
6f34eb2c738de2683f576a9a09a31c0d55890bfb
[ "MIT" ]
null
null
null
u-boot-1.1.6/cpu/mpc85xx/speed.c
XIANG07/u-boot-zjxiang
6f34eb2c738de2683f576a9a09a31c0d55890bfb
[ "MIT" ]
null
null
null
u-boot-1.1.6/cpu/mpc85xx/speed.c
XIANG07/u-boot-zjxiang
6f34eb2c738de2683f576a9a09a31c0d55890bfb
[ "MIT" ]
null
null
null
/* * Copyright 2004 Freescale Semiconductor. * (C) Copyright 2003 Motorola Inc. * Xianghua Xiao, (X.Xiao@motorola.com) * * (C) Copyright 2000 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #include <ppc_asm.tmpl> #include <asm/processor.h> DECLARE_GLOBAL_DATA_PTR; /* --------------------------------------------------------------- */ void get_sys_info (sys_info_t * sysInfo) { volatile immap_t *immap = (immap_t *)CFG_IMMR; volatile ccsr_gur_t *gur = &immap->im_gur; uint plat_ratio,e500_ratio; plat_ratio = (gur->porpllsr) & 0x0000003e; plat_ratio >>= 1; switch(plat_ratio) { case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x08: case 0x09: case 0x0a: case 0x0c: case 0x10: sysInfo->freqSystemBus = plat_ratio * CONFIG_SYS_CLK_FREQ; break; default: sysInfo->freqSystemBus = 0; break; } e500_ratio = (gur->porpllsr) & 0x003f0000; e500_ratio >>= 16; switch(e500_ratio) { case 0x04: sysInfo->freqProcessor = 2*sysInfo->freqSystemBus; break; case 0x05: sysInfo->freqProcessor = 5*sysInfo->freqSystemBus/2; break; case 0x06: sysInfo->freqProcessor = 3*sysInfo->freqSystemBus; break; case 0x07: sysInfo->freqProcessor = 7*sysInfo->freqSystemBus/2; break; default: sysInfo->freqProcessor = 0; break; } } int get_clocks (void) { sys_info_t sys_info; #if defined(CONFIG_CPM2) volatile immap_t *immap = (immap_t *) CFG_IMMR; uint sccr, dfbrg; /* set VCO = 4 * BRG */ immap->im_cpm.im_cpm_intctl.sccr &= 0xfffffffc; sccr = immap->im_cpm.im_cpm_intctl.sccr; dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT; #endif get_sys_info (&sys_info); gd->cpu_clk = sys_info.freqProcessor; gd->bus_clk = sys_info.freqSystemBus; #if defined(CONFIG_CPM2) gd->vco_out = 2*sys_info.freqSystemBus; gd->cpm_clk = gd->vco_out / 2; gd->scc_clk = gd->vco_out / 4; gd->brg_clk = gd->vco_out / (1 << (2 * (dfbrg + 1))); #endif if(gd->cpu_clk != 0) return (0); else return (1); } /******************************************** * get_bus_freq * return system bus freq in Hz *********************************************/ ulong get_bus_freq (ulong dummy) { ulong val; sys_info_t sys_info; get_sys_info (&sys_info); val = sys_info.freqSystemBus; return val; }
24.544
69
0.675033
a9d75f0db02568bee5a1e0f4622b556d8fe00cc0
361
h
C
SimpleHtml/HtmlParser/OSSimpleHTMLStyleCollection.h
gelosi/SimpleHTTP
fc9047df115e8521fa2ac3b75466d59153990477
[ "MIT" ]
1
2016-08-23T17:45:49.000Z
2016-08-23T17:45:49.000Z
SimpleHtml/HtmlParser/OSSimpleHTMLStyleCollection.h
gelosi/SimpleHTTP
fc9047df115e8521fa2ac3b75466d59153990477
[ "MIT" ]
null
null
null
SimpleHtml/HtmlParser/OSSimpleHTMLStyleCollection.h
gelosi/SimpleHTTP
fc9047df115e8521fa2ac3b75466d59153990477
[ "MIT" ]
null
null
null
// // OSSimpleHTMLStyleCollection.h // SimpleHtml // // Created by Oleg Shanyuk on 08/07/16. // Copyright © 2016 AvocadoVentures. All rights reserved. // #import "OSSimpleHTMLStyle.h" #import "OSSimpleHTMLStyleAncor.h" #import "OSSimpleHTMLStyleLineBreak.h" @interface OSSimpleHTMLStyleCollection : NSObject + (NSArray<OSSimpleHTMLStyle *> *)styles; @end
22.5625
58
0.759003
aa57bf3f884137e498879537e2fbc7f06ce4f591
64
h
C
mSD_Shield/mSD_Shield.h
ivankravets/Arduino-Libs
cc6902915721a7a60fbd9bdfb84214d6071c5f25
[ "BSD-3-Clause" ]
149
2015-01-23T20:50:31.000Z
2022-02-20T06:44:28.000Z
mSD_Shield/mSD_Shield.h
ivankravets/Arduino-Libs
cc6902915721a7a60fbd9bdfb84214d6071c5f25
[ "BSD-3-Clause" ]
28
2018-06-22T10:57:56.000Z
2022-03-31T10:09:41.000Z
mSD_Shield/mSD_Shield.h
ivankravets/Arduino-Libs
cc6902915721a7a60fbd9bdfb84214d6071c5f25
[ "BSD-3-Clause" ]
121
2015-01-06T07:30:24.000Z
2022-03-30T19:57:50.000Z
//empty file, workaround for libraries containing only examples
32
63
0.828125
aa9897a954d1a993b5509219c7d1d544f68db471
1,467
h
C
Game/PoolEnemies.h
SokolovVadim/IndustrialProgramming_C-
8d447c6347c8f5957d6e9424447fc0752fbdadc0
[ "MIT" ]
null
null
null
Game/PoolEnemies.h
SokolovVadim/IndustrialProgramming_C-
8d447c6347c8f5957d6e9424447fc0752fbdadc0
[ "MIT" ]
null
null
null
Game/PoolEnemies.h
SokolovVadim/IndustrialProgramming_C-
8d447c6347c8f5957d6e9424447fc0752fbdadc0
[ "MIT" ]
null
null
null
#pragma once #include "Enemy.h" #include "Map.h" #include "Player.h" #include "PoolBullets.h" #include "Audio.h" class PoolEnemies { public: explicit PoolEnemies ( const size_t size, const std::string file, std::string name_, float x, float y, float w, float h); ~PoolEnemies (); void Init ( const std::string file, std::string name_, float x, float y, float w, float h); void Create ( Enemy* enemy, const std::string file, std::string name_, float x, float y, float w, float h); const size_t GetSize (); void DrawPool (sf::RenderWindow & window, const sf::Int64 time); void PrintPosition (); void Update (Map & map, sf::Int64 time, const Player & Hero); void isAttacked (const Player & Hero/*, const int damage*/); void addBullet (bs::PoolBullets & poolBullets, const std::string file, const std::string name_, const float speed, const sf::Int64 time, au::Audio & audio); void bulletCollision (bs::PoolBullets & bPool); const sf::Vector2i getSizeEnemies () const; const bool isPoolAlive () const; private: static const size_t MAX_PULL_SIZE = 200; size_t size_; bool PoolAlive_; Enemy ** m_enemies; Enemy * first_enemy; //void playerCollision(const Player & Hero, const int pos); };
28.211538
76
0.588957
e77588864c4d71c9a0d0f55b2bd473446f588782
934
h
C
bubble/BubbleNode.h
simpleapples/bubble
02d5a4b4cfef487e488804e75d100ff325bdd77e
[ "MIT" ]
15
2017-01-15T17:58:29.000Z
2020-10-14T11:34:56.000Z
bubble/BubbleNode.h
LeiWon9fbank/bubble
02d5a4b4cfef487e488804e75d100ff325bdd77e
[ "MIT" ]
null
null
null
bubble/BubbleNode.h
LeiWon9fbank/bubble
02d5a4b4cfef487e488804e75d100ff325bdd77e
[ "MIT" ]
7
2015-08-10T16:14:34.000Z
2020-10-29T06:38:00.000Z
// // BubbleNode.h // bubble // // Created by Zzy on 11/25/14. // Copyright (c) 2014 zangzhiya. All rights reserved. // #import <SpriteKit/SpriteKit.h> typedef NS_ENUM(NSInteger, BUBBLE_TYPE) { BUBBLE_TYPE_NORMAL = 0, BUBBLE_TYPE_BOMB, }; typedef NS_ENUM(NSInteger, BUBBLE_STATUS) { BUBBLE_STATUS_NORMAL = 0, BUBBLE_STATUS_FlAT, }; typedef NS_ENUM(NSInteger, BUBBLE_POOL_STATUS) { BUBBLE_POOL_STATUS_AVAILABLE = 0, BUBBLE_POOL_STATUS_UNAVAILABLE, }; @interface BubbleNode : SKSpriteNode @property (nonatomic) BUBBLE_TYPE type; @property (nonatomic) BUBBLE_STATUS status; @property (nonatomic) BUBBLE_POOL_STATUS poolStatus; @property (nonatomic) NSInteger poolIndex; - (instancetype)initWithNormalFile:(NSString *)normarlFile flatFile:(NSString *)flatFile; - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)setSize:(CGSize)size; - (void)setStatus:(BUBBLE_STATUS)status; @end
24.578947
89
0.752677
a2985cb64a20a40c3efe53e30b55d2a167bd891a
227
c
C
system/lib/libc/musl/src/ldso/tlsdesc.c
albertobarri/idk
a250884f79e2a484251fc750bb915ecbc962be58
[ "MIT" ]
6,541
2019-01-17T22:13:18.000Z
2022-03-31T07:20:21.000Z
system/lib/libc/musl/src/ldso/tlsdesc.c
albertobarri/idk
a250884f79e2a484251fc750bb915ecbc962be58
[ "MIT" ]
7,584
2019-01-17T22:58:27.000Z
2022-03-31T23:10:22.000Z
system/lib/libc/musl/src/ldso/tlsdesc.c
albertobarri/idk
a250884f79e2a484251fc750bb915ecbc962be58
[ "MIT" ]
1,275
2019-01-19T16:18:04.000Z
2022-03-30T19:32:35.000Z
#include <stddef.h> #include "libc.h" __attribute__((__visibility__("hidden"))) ptrdiff_t __tlsdesc_static(), __tlsdesc_dynamic(); ptrdiff_t __tlsdesc_static() { return 0; } weak_alias(__tlsdesc_static, __tlsdesc_dynamic);
17.461538
50
0.77533
c8ea21832299d75fe05e9c3b9c514027afbd9eaf
2,697
c
C
src/middleware.c
anijjar/ece455
77c8eb28ad6508cff97e77116749ff2aae0c0042
[ "MIT" ]
null
null
null
src/middleware.c
anijjar/ece455
77c8eb28ad6508cff97e77116749ff2aae0c0042
[ "MIT" ]
null
null
null
src/middleware.c
anijjar/ece455
77c8eb28ad6508cff97e77116749ff2aae0c0042
[ "MIT" ]
null
null
null
/* Standard includes. */ #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <time.h> // time() #include "middleware.h" /* Kernel includes. */ #include "stm32f4xx.h" #include "stm32f4_discovery.h" //Use PA1 extern void ADCInit(){ //GPIOA RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); GPIO_InitTypeDef GPIO_InitStruct; GPIO_StructInit(&GPIO_InitStruct); //default parameters GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;//analog mode GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;// no pullup/pulldown GPIO_Init(GPIOA, &GPIO_InitStruct); //ADC1 ADC_DeInit(); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); ADC_InitTypeDef ADC_InitStruct; ADC_InitStruct.ADC_ContinuousConvMode=ENABLE; ADC_InitStruct.ADC_ScanConvMode=DISABLE; ADC_InitStruct.ADC_ExternalTrigConv=ADC_ExternalTrigConv_T1_CC1; ADC_InitStruct.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStruct.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStruct.ADC_NbrOfConversion = 0x01; ADC_Init(ADC1, &ADC_InitStruct); ADC_Cmd(ADC1, ENABLE); ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_144Cycles); ADC1->CR2 |= ADC_CR2_SWSTART;// start conversions } // PA4 = NSS, PA5 = clk, PA7 = output extern void SPIInit(void){ // GPIOA RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); GPIO_InitTypeDef GPIO_InitStruct; GPIO_StructInit(&GPIO_InitStruct); //default parameters GPIO_InitStruct.GPIO_Pin = (GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7); GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;//Alternate Function mode GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_SPI1); GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_SPI1); GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_SPI1); GPIO_Init(GPIOA, &GPIO_InitStruct); // SPI RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); SPI_InitTypeDef SPI_InitStruct; SPI_StructInit(&SPI_InitStruct); SPI_InitStruct.SPI_Direction = SPI_Direction_1Line_Tx; SPI_InitStruct.SPI_Mode = SPI_Mode_Master; SPI_InitStruct.SPI_DataSize = SPI_DataSize_16b; SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low; SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStruct.SPI_NSS = SPI_NSS_Soft; SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256; SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStruct.SPI_CRCPolynomial = 7; SPI_Init(SPI1, &SPI_InitStruct); SPI_Cmd(SPI1, ENABLE); } extern void SPI_Bus_tx(uint16_t data){ SPI1->DR = data; //wait until TXE == 1 //while( ((SPI1->SR) & SPI_I2S_FLAG_TXE) != 1){} } float read_adc(void){ return ADC1->DR; }
29.966667
76
0.798665
080da4d4770dba19e3072bd4c0a4d5b6d9f130a8
3,788
c
C
Project/drivers/c/pc_buffer.c
haocheng1230/ECE353-Fall2020-Project-Space_Avoiders
de0835af3ad7c457cb5748c14495fb9677f06c0f
[ "MIT" ]
null
null
null
Project/drivers/c/pc_buffer.c
haocheng1230/ECE353-Fall2020-Project-Space_Avoiders
de0835af3ad7c457cb5748c14495fb9677f06c0f
[ "MIT" ]
null
null
null
Project/drivers/c/pc_buffer.c
haocheng1230/ECE353-Fall2020-Project-Space_Avoiders
de0835af3ad7c457cb5748c14495fb9677f06c0f
[ "MIT" ]
null
null
null
// Copyright (c) 2015, Joe Krachey // All rights reserved. // // Redistribution and use in source or binary form, with or without modification, // are permitted provided that the following conditions are met: // // 1. Redistributions in source form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in // the documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pc_buffer.h" //***************************************************************************** // Initializes a Producer-Consumer circular buffer. Be sure to allocate // memory using malloc for the array field. // // Parameters // buffer : The address of the circular buffer. // size: Number of entries in the circular buffer. //***************************************************************************** void pc_buffer_init(PC_Buffer *buffer, uint16_t buffer_size) { buffer -> consume_count = 0; buffer -> produce_count = 0; buffer -> BUFFER_SIZE = buffer_size; buffer -> array = malloc(sizeof(char*)*buffer_size); } //***************************************************************************** // Adds a character to the circular buffer. // // Parameters // buffer : The address of the circular buffer. // data : Character to add. //***************************************************************************** void pc_buffer_add(PC_Buffer *buffer, char data) { (buffer -> array)[(buffer->produce_count)%(buffer->BUFFER_SIZE)] = data; buffer -> produce_count ++ ; } //***************************************************************************** // Removes the oldest character from the circular buffer. // // Parameters // buffer : The address of the circular buffer. // data : Address to place the oldest character. //***************************************************************************** void pc_buffer_remove(PC_Buffer *buffer, char *data) { *data = buffer -> array[buffer->consume_count%buffer->BUFFER_SIZE]; buffer -> consume_count ++; } //***************************************************************************** // Returns true if the circular buffer is empty. Returns false if it is not. // // Parameters // buffer : The address of the circular buffer. //***************************************************************************** bool pc_buffer_empty(PC_Buffer *buffer) { if (buffer->produce_count - buffer->consume_count == 0){ return true; } else { return false; } } //***************************************************************************** // Returns true if the circular buffer is full. Returns false if it is not. // // Parameters // buffer : The address of the circular buffer. //***************************************************************************** bool pc_buffer_full(PC_Buffer *buffer) { if (buffer->produce_count-buffer->consume_count==buffer->BUFFER_SIZE){ return true; } else { return false; } }
39.873684
82
0.570222
aeaa2ee03cd826abad28b808066ead2bdcab8f2e
7,211
c
C
cyclone_objects/binaries/audio/line.c
ishankumarkaler/pd-cyclone
3abe27fa0bad7e3602065efd636434abe1f2eb49
[ "BSD-3-Clause" ]
153
2016-02-15T21:39:26.000Z
2022-03-15T05:35:28.000Z
cyclone_objects/binaries/audio/line.c
ishankumarkaler/pd-cyclone
3abe27fa0bad7e3602065efd636434abe1f2eb49
[ "BSD-3-Clause" ]
349
2016-02-27T20:13:59.000Z
2022-03-23T23:25:39.000Z
cyclone_objects/binaries/audio/line.c
ishankumarkaler/pd-cyclone
3abe27fa0bad7e3602065efd636434abe1f2eb49
[ "BSD-3-Clause" ]
20
2016-02-15T23:29:56.000Z
2022-02-12T04:13:31.000Z
/* Copyright (c) 2002-2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ // Added code for the stop, pause and resume messages, fjkraan, 2014-12-02 (alpha57) #include "m_pd.h" #include <common/api.h> #define LINE_MAX_SIZE 128 typedef struct _lineseg { float s_target; float s_delta; } t_lineseg; typedef struct _line { t_object x_obj; float x_value; float x_target; float x_delta; int x_deltaset; float x_inc; float x_biginc; float x_ksr; int x_nleft; int x_retarget; int x_size; /* as allocated */ int x_nsegs; /* as used */ int x_pause; t_lineseg *x_curseg; t_lineseg *x_segs; t_lineseg x_segini[LINE_MAX_SIZE]; t_clock *x_clock; t_outlet *x_bangout; } t_line; static t_class *line_class; static void line_tick(t_line *x) { outlet_bang(x->x_bangout); } static t_int *line_perform(t_int *w) { t_line *x = (t_line *)(w[1]); t_float *out = (t_float *)(w[2]); int nblock = (int)(w[3]); int nxfer = x->x_nleft; float curval = x->x_value; float inc = x->x_inc; float biginc = x->x_biginc; if (x->x_pause) { while (nblock--) *out++ = curval; return (w + 4); } if (PD_BIGORSMALL(curval)) /* LATER rethink */ curval = x->x_value = 0; retarget: if (x->x_retarget) { float target = x->x_curseg->s_target; float delta = x->x_curseg->s_delta; int npoints = delta * x->x_ksr + 0.5; /* LATER rethink */ x->x_nsegs--; x->x_curseg++; while (npoints <= 0) { curval = x->x_value = target; if (x->x_nsegs) { target = x->x_curseg->s_target; delta = x->x_curseg->s_delta; npoints = delta * x->x_ksr + 0.5; /* LATER rethink */ x->x_nsegs--; x->x_curseg++; } else { while (nblock--) *out++ = curval; x->x_nleft = 0; clock_delay(x->x_clock, 0); x->x_retarget = 0; return (w + 4); } } nxfer = x->x_nleft = npoints; inc = x->x_inc = (target - x->x_value) / (float)npoints; x->x_biginc = (int)(w[3]) * inc; biginc = nblock * inc; x->x_target = target; x->x_retarget = 0; } if (nxfer >= nblock) { if ((x->x_nleft -= nblock) == 0) { if (x->x_nsegs) x->x_retarget = 1; else { clock_delay(x->x_clock, 0); } x->x_value = x->x_target; } else x->x_value += biginc; while (nblock--) *out++ = curval, curval += inc; } else if (nxfer > 0) { nblock -= nxfer; do *out++ = curval, curval += inc; while (--nxfer); curval = x->x_value = x->x_target; if (x->x_nsegs) { x->x_retarget = 1; goto retarget; } else { while (nblock--) *out++ = curval; x->x_nleft = 0; clock_delay(x->x_clock, 0); } } else while (nblock--) *out++ = curval; return (w + 4); } static void line_float(t_line *x, t_float f) { if (x->x_deltaset) { x->x_deltaset = 0; x->x_target = f; x->x_nsegs = 1; x->x_curseg = x->x_segs; x->x_curseg->s_target = f; x->x_curseg->s_delta = x->x_delta; x->x_retarget = 1; } else { x->x_value = x->x_target = f; x->x_nsegs = 0; x->x_curseg = 0; x->x_nleft = 0; x->x_retarget = 0; } x->x_pause = 0; } static void line_ft1(t_line *x, t_floatarg f) { x->x_delta = f; x->x_deltaset = (f > 0); } static void line_list(t_line *x, t_symbol *s, int ac, t_atom *av) { int natoms, nsegs, odd; t_atom *ap; t_lineseg *segp; for (natoms = 0, ap = av; natoms < ac; natoms++, ap++) { if (ap->a_type != A_FLOAT) { pd_error(x, "line~: list needs to only contain floats"); return; } } if (!natoms) return; /* CHECKED */ odd = natoms % 2; nsegs = natoms / 2; if (odd) nsegs++; //clip at maxsize if(nsegs > LINE_MAX_SIZE) { nsegs = LINE_MAX_SIZE; odd = 0; }; x->x_nsegs = nsegs; segp = x->x_segs; if (odd) nsegs--; while (nsegs--) { segp->s_target = av++->a_w.w_float; segp->s_delta = av++->a_w.w_float; segp++; } if (odd) { segp->s_target = av->a_w.w_float; segp->s_delta = 0; } x->x_deltaset = 0; x->x_target = x->x_segs->s_target; x->x_curseg = x->x_segs; x->x_retarget = 1; x->x_pause = 0; } static void line_dsp(t_line *x, t_signal **sp) { dsp_add(line_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); x->x_ksr = sp[0]->s_sr * 0.001; } static void line_free(t_line *x) { if (x->x_segs != x->x_segini) freebytes(x->x_segs, x->x_size * sizeof(*x->x_segs)); if (x->x_clock) clock_free(x->x_clock); } static void line_stop(t_line *x) { x->x_nsegs = 0; x->x_nleft = 0; } static void line_pause(t_line *x) { x->x_pause = 1; } static void line_resume(t_line *x) { x->x_pause = 0; } static void *line_new(t_floatarg f) { t_line *x = (t_line *)pd_new(line_class); x->x_value = x->x_target = f; x->x_deltaset = 0; x->x_nleft = 0; x->x_retarget = 0; x->x_size = LINE_MAX_SIZE; x->x_nsegs = 0; x->x_pause = 0; x->x_segs = x->x_segini; x->x_curseg = 0; inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); outlet_new((t_object *)x, &s_signal); x->x_bangout = outlet_new((t_object *)x, &s_bang); x->x_clock = clock_new(x, (t_method)line_tick); return (x); } CYCLONE_OBJ_API void line_tilde_setup(void) { line_class = class_new(gensym("cyclone/line~"), // avoid name clash with vanilla (t_newmethod)line_new, (t_method)line_free, sizeof(t_line), 0, A_DEFFLOAT, 0); class_domainsignalin(line_class, -1); // bug? class_addmethod(line_class, (t_method)line_dsp, gensym("dsp"), A_CANT, 0); class_addfloat(line_class, line_float); class_addlist(line_class, line_list); class_addmethod(line_class, (t_method)line_ft1, gensym("ft1"), A_FLOAT, 0); class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0); class_addmethod(line_class, (t_method)line_pause, gensym("pause"), 0); class_addmethod(line_class, (t_method)line_resume, gensym("resume"), 0); class_sethelpsymbol(line_class, gensym("line~")); } CYCLONE_OBJ_API void Line_tilde_setup(void) { line_class = class_new(gensym("Line~"), // avoid name clash with vanilla (t_newmethod)line_new, (t_method)line_free, sizeof(t_line), 0, A_DEFFLOAT, 0); class_domainsignalin(line_class, -1); // bug? class_addmethod(line_class, (t_method)line_dsp, gensym("dsp"), A_CANT, 0); class_addfloat(line_class, line_float); class_addlist(line_class, line_list); class_addmethod(line_class, (t_method)line_ft1, gensym("ft1"), A_FLOAT, 0); class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0); class_addmethod(line_class, (t_method)line_pause, gensym("pause"), 0); class_addmethod(line_class, (t_method)line_resume, gensym("resume"), 0); class_sethelpsymbol(line_class, gensym("line~")); pd_error(line_class, "Cyclone: please use [cyclone/line~] instead of [Line~] to supress this error"); }
24.865517
105
0.597837
83d11b679e0a70d32bd2cdf1bc7d100c70a1e609
14,879
c
C
app/out_html5/out/h3d/col/Frustum.c
Lerg/hashlink-emscripten
8f5c28a879c78f275fcbc482e1c5f86c08dbe72e
[ "MIT" ]
1
2021-10-03T16:34:38.000Z
2021-10-03T16:34:38.000Z
app/out_html5/out/h3d/col/Frustum.c
Lerg/hashlink-emscripten
8f5c28a879c78f275fcbc482e1c5f86c08dbe72e
[ "MIT" ]
null
null
null
app/out_html5/out/h3d/col/Frustum.c
Lerg/hashlink-emscripten
8f5c28a879c78f275fcbc482e1c5f86c08dbe72e
[ "MIT" ]
null
null
null
// Generated by HLC 4.2.1 (HL v4) #define HLC_BOOT #include <hlc.h> #include <h3d/col/Frustum.h> #include <h3d/Matrix.h> #include <hl/natives.h> #include <h3d/col/Sphere.h> #include <h3d/col/Bounds.h> extern hl_type t$h3d_col_Plane; void h3d_col_Plane_new(h3d__col__Plane,double,double,double,double); void h3d_col_Frustum_loadMatrix(h3d__col__Frustum r0,h3d__Matrix r1) { h3d__col__Plane r2; double r4, r5, r6, r7, r8; r2 = r0->pleft; if( r1 == NULL ) hl_null_access(); r4 = r1->_14; r5 = r1->_11; r4 = r4 + r5; r5 = r1->_24; r6 = r1->_21; r5 = r5 + r6; r6 = r1->_34; r7 = r1->_31; r6 = r6 + r7; r7 = r1->_44; r8 = r1->_41; r7 = r7 + r8; r7 = -r7; if( r2 == NULL ) hl_null_access(); r2->nx = r4; r2->ny = r5; r2->nz = r6; r2->d = r7; r2 = r0->pright; r4 = r1->_14; r5 = r1->_11; r4 = r4 - r5; r5 = r1->_24; r6 = r1->_21; r5 = r5 - r6; r6 = r1->_34; r7 = r1->_31; r6 = r6 - r7; r7 = r1->_41; r8 = r1->_44; r7 = r7 - r8; if( r2 == NULL ) hl_null_access(); r2->nx = r4; r2->ny = r5; r2->nz = r6; r2->d = r7; r2 = r0->ptop; r4 = r1->_14; r5 = r1->_12; r4 = r4 - r5; r5 = r1->_24; r6 = r1->_22; r5 = r5 - r6; r6 = r1->_34; r7 = r1->_32; r6 = r6 - r7; r7 = r1->_42; r8 = r1->_44; r7 = r7 - r8; if( r2 == NULL ) hl_null_access(); r2->nx = r4; r2->ny = r5; r2->nz = r6; r2->d = r7; r2 = r0->pbottom; r4 = r1->_14; r5 = r1->_12; r4 = r4 + r5; r5 = r1->_24; r6 = r1->_22; r5 = r5 + r6; r6 = r1->_34; r7 = r1->_32; r6 = r6 + r7; r7 = r1->_44; r8 = r1->_42; r7 = r7 + r8; r7 = -r7; if( r2 == NULL ) hl_null_access(); r2->nx = r4; r2->ny = r5; r2->nz = r6; r2->d = r7; r2 = r0->pnear; r4 = r1->_13; r5 = r1->_23; r6 = r1->_33; r7 = r1->_43; r7 = -r7; if( r2 == NULL ) hl_null_access(); r2->nx = r4; r2->ny = r5; r2->nz = r6; r2->d = r7; r2 = r0->pfar; r4 = r1->_14; r5 = r1->_13; r4 = r4 - r5; r5 = r1->_24; r6 = r1->_23; r5 = r5 - r6; r6 = r1->_34; r7 = r1->_33; r6 = r6 - r7; r7 = r1->_43; r8 = r1->_44; r7 = r7 - r8; if( r2 == NULL ) hl_null_access(); r2->nx = r4; r2->ny = r5; r2->nz = r6; r2->d = r7; r2 = r0->pleft; r4 = 1.; if( r2 == NULL ) hl_null_access(); r5 = r2->nx; r6 = r2->nx; r5 = r5 * r6; r6 = r2->ny; r7 = r2->ny; r6 = r6 * r7; r5 = r5 + r6; r6 = r2->nz; r7 = r2->nz; r6 = r6 * r7; r5 = r5 + r6; r5 = hl_math_sqrt(r5); r4 = r4 / r5; r5 = r2->nx; r5 = r5 * r4; r2->nx = r5; r5 = r2->ny; r5 = r5 * r4; r2->ny = r5; r5 = r2->nz; r5 = r5 * r4; r2->nz = r5; r5 = r2->d; r5 = r5 * r4; r2->d = r5; r2 = r0->pright; r4 = 1.; if( r2 == NULL ) hl_null_access(); r5 = r2->nx; r6 = r2->nx; r5 = r5 * r6; r6 = r2->ny; r7 = r2->ny; r6 = r6 * r7; r5 = r5 + r6; r6 = r2->nz; r7 = r2->nz; r6 = r6 * r7; r5 = r5 + r6; r5 = hl_math_sqrt(r5); r4 = r4 / r5; r5 = r2->nx; r5 = r5 * r4; r2->nx = r5; r5 = r2->ny; r5 = r5 * r4; r2->ny = r5; r5 = r2->nz; r5 = r5 * r4; r2->nz = r5; r5 = r2->d; r5 = r5 * r4; r2->d = r5; r2 = r0->ptop; r4 = 1.; if( r2 == NULL ) hl_null_access(); r5 = r2->nx; r6 = r2->nx; r5 = r5 * r6; r6 = r2->ny; r7 = r2->ny; r6 = r6 * r7; r5 = r5 + r6; r6 = r2->nz; r7 = r2->nz; r6 = r6 * r7; r5 = r5 + r6; r5 = hl_math_sqrt(r5); r4 = r4 / r5; r5 = r2->nx; r5 = r5 * r4; r2->nx = r5; r5 = r2->ny; r5 = r5 * r4; r2->ny = r5; r5 = r2->nz; r5 = r5 * r4; r2->nz = r5; r5 = r2->d; r5 = r5 * r4; r2->d = r5; r2 = r0->pbottom; r4 = 1.; if( r2 == NULL ) hl_null_access(); r5 = r2->nx; r6 = r2->nx; r5 = r5 * r6; r6 = r2->ny; r7 = r2->ny; r6 = r6 * r7; r5 = r5 + r6; r6 = r2->nz; r7 = r2->nz; r6 = r6 * r7; r5 = r5 + r6; r5 = hl_math_sqrt(r5); r4 = r4 / r5; r5 = r2->nx; r5 = r5 * r4; r2->nx = r5; r5 = r2->ny; r5 = r5 * r4; r2->ny = r5; r5 = r2->nz; r5 = r5 * r4; r2->nz = r5; r5 = r2->d; r5 = r5 * r4; r2->d = r5; r2 = r0->pnear; r4 = 1.; if( r2 == NULL ) hl_null_access(); r5 = r2->nx; r6 = r2->nx; r5 = r5 * r6; r6 = r2->ny; r7 = r2->ny; r6 = r6 * r7; r5 = r5 + r6; r6 = r2->nz; r7 = r2->nz; r6 = r6 * r7; r5 = r5 + r6; r5 = hl_math_sqrt(r5); r4 = r4 / r5; r5 = r2->nx; r5 = r5 * r4; r2->nx = r5; r5 = r2->ny; r5 = r5 * r4; r2->ny = r5; r5 = r2->nz; r5 = r5 * r4; r2->nz = r5; r5 = r2->d; r5 = r5 * r4; r2->d = r5; r2 = r0->pfar; r4 = 1.; if( r2 == NULL ) hl_null_access(); r5 = r2->nx; r6 = r2->nx; r5 = r5 * r6; r6 = r2->ny; r7 = r2->ny; r6 = r6 * r7; r5 = r5 + r6; r6 = r2->nz; r7 = r2->nz; r6 = r6 * r7; r5 = r5 + r6; r5 = hl_math_sqrt(r5); r4 = r4 / r5; r5 = r2->nx; r5 = r5 * r4; r2->nx = r5; r5 = r2->ny; r5 = r5 * r4; r2->ny = r5; r5 = r2->nz; r5 = r5 * r4; r2->nz = r5; r5 = r2->d; r5 = r5 * r4; r2->d = r5; return; } bool h3d_col_Frustum_hasSphere(h3d__col__Frustum r0,h3d__col__Sphere r1) { bool r9; h3d__col__Plane r5, r7, r10, r11, r12, r13; double r2, r3, r4, r6, r8; if( r1 == NULL ) hl_null_access(); r2 = r1->x; r3 = r1->y; r4 = r1->z; r5 = r0->pleft; if( r5 == NULL ) hl_null_access(); r6 = r5->nx; r6 = r6 * r2; r8 = r5->ny; r8 = r8 * r3; r6 = r6 + r8; r8 = r5->nz; r8 = r8 * r4; r6 = r6 + r8; r8 = r5->d; r6 = r6 - r8; r8 = r1->r; r8 = -r8; if( !(r6 < r8) ) goto label$beb075a_2_21; r9 = false; return r9; label$beb075a_2_21: r7 = r0->pright; if( r7 == NULL ) hl_null_access(); r6 = r7->nx; r6 = r6 * r2; r8 = r7->ny; r8 = r8 * r3; r6 = r6 + r8; r8 = r7->nz; r8 = r8 * r4; r6 = r6 + r8; r8 = r7->d; r6 = r6 - r8; r8 = r1->r; r8 = -r8; if( !(r6 < r8) ) goto label$beb075a_2_38; r9 = false; return r9; label$beb075a_2_38: r10 = r0->ptop; if( r10 == NULL ) hl_null_access(); r6 = r10->nx; r6 = r6 * r2; r8 = r10->ny; r8 = r8 * r3; r6 = r6 + r8; r8 = r10->nz; r8 = r8 * r4; r6 = r6 + r8; r8 = r10->d; r6 = r6 - r8; r8 = r1->r; r8 = -r8; if( !(r6 < r8) ) goto label$beb075a_2_55; r9 = false; return r9; label$beb075a_2_55: r11 = r0->pbottom; if( r11 == NULL ) hl_null_access(); r6 = r11->nx; r6 = r6 * r2; r8 = r11->ny; r8 = r8 * r3; r6 = r6 + r8; r8 = r11->nz; r8 = r8 * r4; r6 = r6 + r8; r8 = r11->d; r6 = r6 - r8; r8 = r1->r; r8 = -r8; if( !(r6 < r8) ) goto label$beb075a_2_72; r9 = false; return r9; label$beb075a_2_72: r9 = r0->checkNearFar; if( !r9 ) goto label$beb075a_2_108; r12 = r0->pnear; if( r12 == NULL ) hl_null_access(); r6 = r12->nx; r6 = r6 * r2; r8 = r12->ny; r8 = r8 * r3; r6 = r6 + r8; r8 = r12->nz; r8 = r8 * r4; r6 = r6 + r8; r8 = r12->d; r6 = r6 - r8; r8 = r1->r; r8 = -r8; if( !(r6 < r8) ) goto label$beb075a_2_91; r9 = false; return r9; label$beb075a_2_91: r13 = r0->pfar; if( r13 == NULL ) hl_null_access(); r6 = r13->nx; r6 = r6 * r2; r8 = r13->ny; r8 = r8 * r3; r6 = r6 + r8; r8 = r13->nz; r8 = r8 * r4; r6 = r6 + r8; r8 = r13->d; r6 = r6 - r8; r8 = r1->r; r8 = -r8; if( !(r6 < r8) ) goto label$beb075a_2_108; r9 = false; return r9; label$beb075a_2_108: r9 = true; return r9; } bool h3d_col_Frustum_hasBounds(h3d__col__Frustum r0,h3d__col__Bounds r1) { bool r12; h3d__col__Plane r2, r4, r13, r19, r25, r31; double r3, r5, r6, r7, r8, r9, r10, r11, r14, r15, r16, r17, r18, r20, r21, r22, r23, r24, r26, r27, r28, r29, r30, r32, r33, r34, r35, r36, r37, r38, r39, r40, r41; r2 = r0->pleft; if( r2 == NULL ) hl_null_access(); r3 = r2->nx; r5 = r2->ny; r6 = r2->nz; if( r1 == NULL ) hl_null_access(); r8 = r1->xMax; r9 = r1->xMin; r8 = r8 + r9; r7 = r3 * r8; r9 = r1->yMax; r10 = r1->yMin; r9 = r9 + r10; r8 = r5 * r9; r7 = r7 + r8; r9 = r1->zMax; r10 = r1->zMin; r9 = r9 + r10; r8 = r6 * r9; r7 = r7 + r8; r9 = 0.; if( !(r3 < r9) ) goto label$beb075a_3_24; r8 = -r3; r3 = r8; label$beb075a_3_24: r9 = 0.; if( !(r5 < r9) ) goto label$beb075a_3_28; r8 = -r5; r5 = r8; label$beb075a_3_28: r9 = 0.; if( !(r6 < r9) ) goto label$beb075a_3_32; r8 = -r6; r6 = r8; label$beb075a_3_32: r9 = r1->xMax; r10 = r1->xMin; r9 = r9 - r10; r8 = r3 * r9; r10 = r1->yMax; r11 = r1->yMin; r10 = r10 - r11; r9 = r5 * r10; r8 = r8 + r9; r10 = r1->zMax; r11 = r1->zMin; r10 = r10 - r11; r9 = r6 * r10; r8 = r8 + r9; r9 = r7 + r8; r10 = r2->d; r11 = 2.; r10 = r10 * r11; r9 = r9 - r10; r10 = 0.; if( !(r9 < r10) ) goto label$beb075a_3_55; r12 = false; return r12; label$beb075a_3_55: r4 = r0->pright; if( r4 == NULL ) hl_null_access(); r9 = r4->nx; r10 = r4->ny; r11 = r4->nz; r15 = r1->xMax; r16 = r1->xMin; r15 = r15 + r16; r14 = r9 * r15; r16 = r1->yMax; r17 = r1->yMin; r16 = r16 + r17; r15 = r10 * r16; r14 = r14 + r15; r16 = r1->zMax; r17 = r1->zMin; r16 = r16 + r17; r15 = r11 * r16; r14 = r14 + r15; r16 = 0.; if( !(r9 < r16) ) goto label$beb075a_3_78; r15 = -r9; r9 = r15; label$beb075a_3_78: r16 = 0.; if( !(r10 < r16) ) goto label$beb075a_3_82; r15 = -r10; r10 = r15; label$beb075a_3_82: r16 = 0.; if( !(r11 < r16) ) goto label$beb075a_3_86; r15 = -r11; r11 = r15; label$beb075a_3_86: r16 = r1->xMax; r17 = r1->xMin; r16 = r16 - r17; r15 = r9 * r16; r17 = r1->yMax; r18 = r1->yMin; r17 = r17 - r18; r16 = r10 * r17; r15 = r15 + r16; r17 = r1->zMax; r18 = r1->zMin; r17 = r17 - r18; r16 = r11 * r17; r15 = r15 + r16; r16 = r14 + r15; r17 = r4->d; r18 = 2.; r17 = r17 * r18; r16 = r16 - r17; r17 = 0.; if( !(r16 < r17) ) goto label$beb075a_3_109; r12 = false; return r12; label$beb075a_3_109: r13 = r0->ptop; if( r13 == NULL ) hl_null_access(); r16 = r13->nx; r17 = r13->ny; r18 = r13->nz; r21 = r1->xMax; r22 = r1->xMin; r21 = r21 + r22; r20 = r16 * r21; r22 = r1->yMax; r23 = r1->yMin; r22 = r22 + r23; r21 = r17 * r22; r20 = r20 + r21; r22 = r1->zMax; r23 = r1->zMin; r22 = r22 + r23; r21 = r18 * r22; r20 = r20 + r21; r22 = 0.; if( !(r16 < r22) ) goto label$beb075a_3_132; r21 = -r16; r16 = r21; label$beb075a_3_132: r22 = 0.; if( !(r17 < r22) ) goto label$beb075a_3_136; r21 = -r17; r17 = r21; label$beb075a_3_136: r22 = 0.; if( !(r18 < r22) ) goto label$beb075a_3_140; r21 = -r18; r18 = r21; label$beb075a_3_140: r22 = r1->xMax; r23 = r1->xMin; r22 = r22 - r23; r21 = r16 * r22; r23 = r1->yMax; r24 = r1->yMin; r23 = r23 - r24; r22 = r17 * r23; r21 = r21 + r22; r23 = r1->zMax; r24 = r1->zMin; r23 = r23 - r24; r22 = r18 * r23; r21 = r21 + r22; r22 = r20 + r21; r23 = r13->d; r24 = 2.; r23 = r23 * r24; r22 = r22 - r23; r23 = 0.; if( !(r22 < r23) ) goto label$beb075a_3_163; r12 = false; return r12; label$beb075a_3_163: r19 = r0->ptop; if( r19 == NULL ) hl_null_access(); r22 = r19->nx; r23 = r19->ny; r24 = r19->nz; r27 = r1->xMax; r28 = r1->xMin; r27 = r27 + r28; r26 = r22 * r27; r28 = r1->yMax; r29 = r1->yMin; r28 = r28 + r29; r27 = r23 * r28; r26 = r26 + r27; r28 = r1->zMax; r29 = r1->zMin; r28 = r28 + r29; r27 = r24 * r28; r26 = r26 + r27; r28 = 0.; if( !(r22 < r28) ) goto label$beb075a_3_186; r27 = -r22; r22 = r27; label$beb075a_3_186: r28 = 0.; if( !(r23 < r28) ) goto label$beb075a_3_190; r27 = -r23; r23 = r27; label$beb075a_3_190: r28 = 0.; if( !(r24 < r28) ) goto label$beb075a_3_194; r27 = -r24; r24 = r27; label$beb075a_3_194: r28 = r1->xMax; r29 = r1->xMin; r28 = r28 - r29; r27 = r22 * r28; r29 = r1->yMax; r30 = r1->yMin; r29 = r29 - r30; r28 = r23 * r29; r27 = r27 + r28; r29 = r1->zMax; r30 = r1->zMin; r29 = r29 - r30; r28 = r24 * r29; r27 = r27 + r28; r28 = r26 + r27; r29 = r19->d; r30 = 2.; r29 = r29 * r30; r28 = r28 - r29; r29 = 0.; if( !(r28 < r29) ) goto label$beb075a_3_217; r12 = false; return r12; label$beb075a_3_217: r25 = r0->pnear; if( r25 == NULL ) hl_null_access(); r28 = r25->nx; r29 = r25->ny; r30 = r25->nz; r33 = r1->xMax; r34 = r1->xMin; r33 = r33 + r34; r32 = r28 * r33; r34 = r1->yMax; r35 = r1->yMin; r34 = r34 + r35; r33 = r29 * r34; r32 = r32 + r33; r34 = r1->zMax; r35 = r1->zMin; r34 = r34 + r35; r33 = r30 * r34; r32 = r32 + r33; r34 = 0.; if( !(r28 < r34) ) goto label$beb075a_3_240; r33 = -r28; r28 = r33; label$beb075a_3_240: r34 = 0.; if( !(r29 < r34) ) goto label$beb075a_3_244; r33 = -r29; r29 = r33; label$beb075a_3_244: r34 = 0.; if( !(r30 < r34) ) goto label$beb075a_3_248; r33 = -r30; r30 = r33; label$beb075a_3_248: r34 = r1->xMax; r35 = r1->xMin; r34 = r34 - r35; r33 = r28 * r34; r35 = r1->yMax; r36 = r1->yMin; r35 = r35 - r36; r34 = r29 * r35; r33 = r33 + r34; r35 = r1->zMax; r36 = r1->zMin; r35 = r35 - r36; r34 = r30 * r35; r33 = r33 + r34; r34 = r32 + r33; r35 = r25->d; r36 = 2.; r35 = r35 * r36; r34 = r34 - r35; r35 = 0.; if( !(r34 < r35) ) goto label$beb075a_3_271; r12 = false; return r12; label$beb075a_3_271: r31 = r0->pfar; if( r31 == NULL ) hl_null_access(); r34 = r31->nx; r35 = r31->ny; r36 = r31->nz; r38 = r1->xMax; r39 = r1->xMin; r38 = r38 + r39; r37 = r34 * r38; r39 = r1->yMax; r40 = r1->yMin; r39 = r39 + r40; r38 = r35 * r39; r37 = r37 + r38; r39 = r1->zMax; r40 = r1->zMin; r39 = r39 + r40; r38 = r36 * r39; r37 = r37 + r38; r39 = 0.; if( !(r34 < r39) ) goto label$beb075a_3_294; r38 = -r34; r34 = r38; label$beb075a_3_294: r39 = 0.; if( !(r35 < r39) ) goto label$beb075a_3_298; r38 = -r35; r35 = r38; label$beb075a_3_298: r39 = 0.; if( !(r36 < r39) ) goto label$beb075a_3_302; r38 = -r36; r36 = r38; label$beb075a_3_302: r39 = r1->xMax; r40 = r1->xMin; r39 = r39 - r40; r38 = r34 * r39; r40 = r1->yMax; r41 = r1->yMin; r40 = r40 - r41; r39 = r35 * r40; r38 = r38 + r39; r40 = r1->zMax; r41 = r1->zMin; r40 = r40 - r41; r39 = r36 * r40; r38 = r38 + r39; r39 = r37 + r38; r40 = r31->d; r41 = 2.; r40 = r40 * r41; r39 = r39 - r40; r40 = 0.; if( !(r39 < r40) ) goto label$beb075a_3_325; r12 = false; return r12; label$beb075a_3_325: r12 = true; return r12; } void h3d_col_Frustum_new(h3d__col__Frustum r0,h3d__Matrix r1) { bool r2; h3d__col__Plane r3; double r4, r5, r6, r7; r2 = true; r0->checkNearFar = r2; r3 = (h3d__col__Plane)hl_alloc_obj(&t$h3d_col_Plane); r4 = 1.; r5 = 0.; r6 = 0.; r7 = 0.; h3d_col_Plane_new(r3,r4,r5,r6,r7); r0->pleft = r3; r3 = (h3d__col__Plane)hl_alloc_obj(&t$h3d_col_Plane); r4 = 1.; r5 = 0.; r6 = 0.; r7 = 0.; h3d_col_Plane_new(r3,r4,r5,r6,r7); r0->pright = r3; r3 = (h3d__col__Plane)hl_alloc_obj(&t$h3d_col_Plane); r4 = 1.; r5 = 0.; r6 = 0.; r7 = 0.; h3d_col_Plane_new(r3,r4,r5,r6,r7); r0->ptop = r3; r3 = (h3d__col__Plane)hl_alloc_obj(&t$h3d_col_Plane); r4 = 1.; r5 = 0.; r6 = 0.; r7 = 0.; h3d_col_Plane_new(r3,r4,r5,r6,r7); r0->pbottom = r3; r3 = (h3d__col__Plane)hl_alloc_obj(&t$h3d_col_Plane); r4 = 1.; r5 = 0.; r6 = 0.; r7 = 0.; h3d_col_Plane_new(r3,r4,r5,r6,r7); r0->pnear = r3; r3 = (h3d__col__Plane)hl_alloc_obj(&t$h3d_col_Plane); r4 = 1.; r5 = 0.; r6 = 0.; r7 = 0.; h3d_col_Plane_new(r3,r4,r5,r6,r7); r0->pfar = r3; if( !r1 ) goto label$beb075a_4_46; h3d_col_Frustum_loadMatrix(r0,r1); label$beb075a_4_46: return; }
18.078979
166
0.536192
26e221dabdebd00341c321f561b7634597aa2a2a
1,380
h
C
resource.h
rherardi/xmlset
f9e9071d6745e08cd7d43c34a052a452f29bc40c
[ "Apache-2.0" ]
null
null
null
resource.h
rherardi/xmlset
f9e9071d6745e08cd7d43c34a052a452f29bc40c
[ "Apache-2.0" ]
null
null
null
resource.h
rherardi/xmlset
f9e9071d6745e08cd7d43c34a052a452f29bc40c
[ "Apache-2.0" ]
null
null
null
//{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by resource.rc // #define IDS_TITLE 1 #define IDS_VERSION 2 #define IDS_USAGE 3 #define IDS_OPTION_FILE 4 #define IDS_OPTION_SETTING 5 #define IDS_OPTION_ELEMENT 5 #define IDS_OPTION_VALUE 6 #define IDS_OPTION_ATTRIBUTE 7 #define IDS_OPTION_SLASH_INVERSION 8 #define IDS_OPTION_SLASH_REMOVE_TRAIL 9 #define IDS_OPTION_READ_ONLY 10 #define IDS_OPTION_VERBOSE 11 #define IDS_OPT_ERR_ILLEGAL_OPTION 100 #define IDS_OPT_ERR_NOHANDLER 101 #define IDI_ICON_GSS 101 #define IDS_OPT_ERR_MISSEDARG 102 #define IDS_ERR_FILE_OPEN 103 #define IDS_ERR_ELEMENT 104 #define IDS_ERR_ATTRIBUTE 106 #define IDS_EXIT_CODE 200 #define IDS_ENTER_METHOD 201 #define IDS_EXIT_METHOD 202 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
36.315789
54
0.619565
d825db000283757bd3c94b072c9cb6bb651da8f8
24,143
h
C
eembc/CIFAR10_ResNetv1/my-hls-test-quantized-tiny2/myproject_prj/solution1/syn/systemc/zeropad2d_cl_array_array_ap_fixed_32u_config20_s.h
anmeza/platform_ml_models
ba8011a289a96013dd6f7a5b58eb1072f04d6bf0
[ "RSA-MD" ]
1
2021-12-21T18:19:27.000Z
2021-12-21T18:19:27.000Z
eembc/CIFAR10_ResNetv1/my-hls-test-quantized-tiny2/myproject_prj/solution1/syn/systemc/zeropad2d_cl_array_array_ap_fixed_32u_config20_s.h
anmeza/platform_ml_models
ba8011a289a96013dd6f7a5b58eb1072f04d6bf0
[ "RSA-MD" ]
null
null
null
eembc/CIFAR10_ResNetv1/my-hls-test-quantized-tiny2/myproject_prj/solution1/syn/systemc/zeropad2d_cl_array_array_ap_fixed_32u_config20_s.h
anmeza/platform_ml_models
ba8011a289a96013dd6f7a5b58eb1072f04d6bf0
[ "RSA-MD" ]
null
null
null
// ============================================================== // RTL generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and OpenCL // Version: 2020.1 // Copyright (C) 1986-2020 Xilinx, Inc. All Rights Reserved. // // =========================================================== #ifndef _zeropad2d_cl_array_array_ap_fixed_32u_config20_s_HH_ #define _zeropad2d_cl_array_array_ap_fixed_32u_config20_s_HH_ #include "systemc.h" #include "AESL_pkg.h" namespace ap_rtl { struct zeropad2d_cl_array_array_ap_fixed_32u_config20_s : public sc_module { // Port declarations 202 sc_in_clk ap_clk; sc_in< sc_logic > ap_rst; sc_in< sc_logic > ap_start; sc_in< sc_logic > start_full_n; sc_out< sc_logic > ap_done; sc_in< sc_logic > ap_continue; sc_out< sc_logic > ap_idle; sc_out< sc_logic > ap_ready; sc_out< sc_logic > start_out; sc_out< sc_logic > start_write; sc_in< sc_lv<8> > data_V_data_0_V_dout; sc_in< sc_logic > data_V_data_0_V_empty_n; sc_out< sc_logic > data_V_data_0_V_read; sc_in< sc_lv<8> > data_V_data_1_V_dout; sc_in< sc_logic > data_V_data_1_V_empty_n; sc_out< sc_logic > data_V_data_1_V_read; sc_in< sc_lv<8> > data_V_data_2_V_dout; sc_in< sc_logic > data_V_data_2_V_empty_n; sc_out< sc_logic > data_V_data_2_V_read; sc_in< sc_lv<8> > data_V_data_3_V_dout; sc_in< sc_logic > data_V_data_3_V_empty_n; sc_out< sc_logic > data_V_data_3_V_read; sc_in< sc_lv<8> > data_V_data_4_V_dout; sc_in< sc_logic > data_V_data_4_V_empty_n; sc_out< sc_logic > data_V_data_4_V_read; sc_in< sc_lv<8> > data_V_data_5_V_dout; sc_in< sc_logic > data_V_data_5_V_empty_n; sc_out< sc_logic > data_V_data_5_V_read; sc_in< sc_lv<8> > data_V_data_6_V_dout; sc_in< sc_logic > data_V_data_6_V_empty_n; sc_out< sc_logic > data_V_data_6_V_read; sc_in< sc_lv<8> > data_V_data_7_V_dout; sc_in< sc_logic > data_V_data_7_V_empty_n; sc_out< sc_logic > data_V_data_7_V_read; sc_in< sc_lv<8> > data_V_data_8_V_dout; sc_in< sc_logic > data_V_data_8_V_empty_n; sc_out< sc_logic > data_V_data_8_V_read; sc_in< sc_lv<8> > data_V_data_9_V_dout; sc_in< sc_logic > data_V_data_9_V_empty_n; sc_out< sc_logic > data_V_data_9_V_read; sc_in< sc_lv<8> > data_V_data_10_V_dout; sc_in< sc_logic > data_V_data_10_V_empty_n; sc_out< sc_logic > data_V_data_10_V_read; sc_in< sc_lv<8> > data_V_data_11_V_dout; sc_in< sc_logic > data_V_data_11_V_empty_n; sc_out< sc_logic > data_V_data_11_V_read; sc_in< sc_lv<8> > data_V_data_12_V_dout; sc_in< sc_logic > data_V_data_12_V_empty_n; sc_out< sc_logic > data_V_data_12_V_read; sc_in< sc_lv<8> > data_V_data_13_V_dout; sc_in< sc_logic > data_V_data_13_V_empty_n; sc_out< sc_logic > data_V_data_13_V_read; sc_in< sc_lv<8> > data_V_data_14_V_dout; sc_in< sc_logic > data_V_data_14_V_empty_n; sc_out< sc_logic > data_V_data_14_V_read; sc_in< sc_lv<8> > data_V_data_15_V_dout; sc_in< sc_logic > data_V_data_15_V_empty_n; sc_out< sc_logic > data_V_data_15_V_read; sc_in< sc_lv<8> > data_V_data_16_V_dout; sc_in< sc_logic > data_V_data_16_V_empty_n; sc_out< sc_logic > data_V_data_16_V_read; sc_in< sc_lv<8> > data_V_data_17_V_dout; sc_in< sc_logic > data_V_data_17_V_empty_n; sc_out< sc_logic > data_V_data_17_V_read; sc_in< sc_lv<8> > data_V_data_18_V_dout; sc_in< sc_logic > data_V_data_18_V_empty_n; sc_out< sc_logic > data_V_data_18_V_read; sc_in< sc_lv<8> > data_V_data_19_V_dout; sc_in< sc_logic > data_V_data_19_V_empty_n; sc_out< sc_logic > data_V_data_19_V_read; sc_in< sc_lv<8> > data_V_data_20_V_dout; sc_in< sc_logic > data_V_data_20_V_empty_n; sc_out< sc_logic > data_V_data_20_V_read; sc_in< sc_lv<8> > data_V_data_21_V_dout; sc_in< sc_logic > data_V_data_21_V_empty_n; sc_out< sc_logic > data_V_data_21_V_read; sc_in< sc_lv<8> > data_V_data_22_V_dout; sc_in< sc_logic > data_V_data_22_V_empty_n; sc_out< sc_logic > data_V_data_22_V_read; sc_in< sc_lv<8> > data_V_data_23_V_dout; sc_in< sc_logic > data_V_data_23_V_empty_n; sc_out< sc_logic > data_V_data_23_V_read; sc_in< sc_lv<8> > data_V_data_24_V_dout; sc_in< sc_logic > data_V_data_24_V_empty_n; sc_out< sc_logic > data_V_data_24_V_read; sc_in< sc_lv<8> > data_V_data_25_V_dout; sc_in< sc_logic > data_V_data_25_V_empty_n; sc_out< sc_logic > data_V_data_25_V_read; sc_in< sc_lv<8> > data_V_data_26_V_dout; sc_in< sc_logic > data_V_data_26_V_empty_n; sc_out< sc_logic > data_V_data_26_V_read; sc_in< sc_lv<8> > data_V_data_27_V_dout; sc_in< sc_logic > data_V_data_27_V_empty_n; sc_out< sc_logic > data_V_data_27_V_read; sc_in< sc_lv<8> > data_V_data_28_V_dout; sc_in< sc_logic > data_V_data_28_V_empty_n; sc_out< sc_logic > data_V_data_28_V_read; sc_in< sc_lv<8> > data_V_data_29_V_dout; sc_in< sc_logic > data_V_data_29_V_empty_n; sc_out< sc_logic > data_V_data_29_V_read; sc_in< sc_lv<8> > data_V_data_30_V_dout; sc_in< sc_logic > data_V_data_30_V_empty_n; sc_out< sc_logic > data_V_data_30_V_read; sc_in< sc_lv<8> > data_V_data_31_V_dout; sc_in< sc_logic > data_V_data_31_V_empty_n; sc_out< sc_logic > data_V_data_31_V_read; sc_out< sc_lv<8> > res_V_data_0_V_din; sc_in< sc_logic > res_V_data_0_V_full_n; sc_out< sc_logic > res_V_data_0_V_write; sc_out< sc_lv<8> > res_V_data_1_V_din; sc_in< sc_logic > res_V_data_1_V_full_n; sc_out< sc_logic > res_V_data_1_V_write; sc_out< sc_lv<8> > res_V_data_2_V_din; sc_in< sc_logic > res_V_data_2_V_full_n; sc_out< sc_logic > res_V_data_2_V_write; sc_out< sc_lv<8> > res_V_data_3_V_din; sc_in< sc_logic > res_V_data_3_V_full_n; sc_out< sc_logic > res_V_data_3_V_write; sc_out< sc_lv<8> > res_V_data_4_V_din; sc_in< sc_logic > res_V_data_4_V_full_n; sc_out< sc_logic > res_V_data_4_V_write; sc_out< sc_lv<8> > res_V_data_5_V_din; sc_in< sc_logic > res_V_data_5_V_full_n; sc_out< sc_logic > res_V_data_5_V_write; sc_out< sc_lv<8> > res_V_data_6_V_din; sc_in< sc_logic > res_V_data_6_V_full_n; sc_out< sc_logic > res_V_data_6_V_write; sc_out< sc_lv<8> > res_V_data_7_V_din; sc_in< sc_logic > res_V_data_7_V_full_n; sc_out< sc_logic > res_V_data_7_V_write; sc_out< sc_lv<8> > res_V_data_8_V_din; sc_in< sc_logic > res_V_data_8_V_full_n; sc_out< sc_logic > res_V_data_8_V_write; sc_out< sc_lv<8> > res_V_data_9_V_din; sc_in< sc_logic > res_V_data_9_V_full_n; sc_out< sc_logic > res_V_data_9_V_write; sc_out< sc_lv<8> > res_V_data_10_V_din; sc_in< sc_logic > res_V_data_10_V_full_n; sc_out< sc_logic > res_V_data_10_V_write; sc_out< sc_lv<8> > res_V_data_11_V_din; sc_in< sc_logic > res_V_data_11_V_full_n; sc_out< sc_logic > res_V_data_11_V_write; sc_out< sc_lv<8> > res_V_data_12_V_din; sc_in< sc_logic > res_V_data_12_V_full_n; sc_out< sc_logic > res_V_data_12_V_write; sc_out< sc_lv<8> > res_V_data_13_V_din; sc_in< sc_logic > res_V_data_13_V_full_n; sc_out< sc_logic > res_V_data_13_V_write; sc_out< sc_lv<8> > res_V_data_14_V_din; sc_in< sc_logic > res_V_data_14_V_full_n; sc_out< sc_logic > res_V_data_14_V_write; sc_out< sc_lv<8> > res_V_data_15_V_din; sc_in< sc_logic > res_V_data_15_V_full_n; sc_out< sc_logic > res_V_data_15_V_write; sc_out< sc_lv<8> > res_V_data_16_V_din; sc_in< sc_logic > res_V_data_16_V_full_n; sc_out< sc_logic > res_V_data_16_V_write; sc_out< sc_lv<8> > res_V_data_17_V_din; sc_in< sc_logic > res_V_data_17_V_full_n; sc_out< sc_logic > res_V_data_17_V_write; sc_out< sc_lv<8> > res_V_data_18_V_din; sc_in< sc_logic > res_V_data_18_V_full_n; sc_out< sc_logic > res_V_data_18_V_write; sc_out< sc_lv<8> > res_V_data_19_V_din; sc_in< sc_logic > res_V_data_19_V_full_n; sc_out< sc_logic > res_V_data_19_V_write; sc_out< sc_lv<8> > res_V_data_20_V_din; sc_in< sc_logic > res_V_data_20_V_full_n; sc_out< sc_logic > res_V_data_20_V_write; sc_out< sc_lv<8> > res_V_data_21_V_din; sc_in< sc_logic > res_V_data_21_V_full_n; sc_out< sc_logic > res_V_data_21_V_write; sc_out< sc_lv<8> > res_V_data_22_V_din; sc_in< sc_logic > res_V_data_22_V_full_n; sc_out< sc_logic > res_V_data_22_V_write; sc_out< sc_lv<8> > res_V_data_23_V_din; sc_in< sc_logic > res_V_data_23_V_full_n; sc_out< sc_logic > res_V_data_23_V_write; sc_out< sc_lv<8> > res_V_data_24_V_din; sc_in< sc_logic > res_V_data_24_V_full_n; sc_out< sc_logic > res_V_data_24_V_write; sc_out< sc_lv<8> > res_V_data_25_V_din; sc_in< sc_logic > res_V_data_25_V_full_n; sc_out< sc_logic > res_V_data_25_V_write; sc_out< sc_lv<8> > res_V_data_26_V_din; sc_in< sc_logic > res_V_data_26_V_full_n; sc_out< sc_logic > res_V_data_26_V_write; sc_out< sc_lv<8> > res_V_data_27_V_din; sc_in< sc_logic > res_V_data_27_V_full_n; sc_out< sc_logic > res_V_data_27_V_write; sc_out< sc_lv<8> > res_V_data_28_V_din; sc_in< sc_logic > res_V_data_28_V_full_n; sc_out< sc_logic > res_V_data_28_V_write; sc_out< sc_lv<8> > res_V_data_29_V_din; sc_in< sc_logic > res_V_data_29_V_full_n; sc_out< sc_logic > res_V_data_29_V_write; sc_out< sc_lv<8> > res_V_data_30_V_din; sc_in< sc_logic > res_V_data_30_V_full_n; sc_out< sc_logic > res_V_data_30_V_write; sc_out< sc_lv<8> > res_V_data_31_V_din; sc_in< sc_logic > res_V_data_31_V_full_n; sc_out< sc_logic > res_V_data_31_V_write; // Module declarations zeropad2d_cl_array_array_ap_fixed_32u_config20_s(sc_module_name name); SC_HAS_PROCESS(zeropad2d_cl_array_array_ap_fixed_32u_config20_s); ~zeropad2d_cl_array_array_ap_fixed_32u_config20_s(); sc_trace_file* mVcdFile; sc_signal< sc_logic > real_start; sc_signal< sc_logic > start_once_reg; sc_signal< sc_logic > ap_done_reg; sc_signal< sc_lv<7> > ap_CS_fsm; sc_signal< sc_logic > ap_CS_fsm_state1; sc_signal< sc_logic > internal_ap_ready; sc_signal< sc_logic > data_V_data_0_V_blk_n; sc_signal< sc_logic > ap_CS_fsm_state4; sc_signal< sc_lv<1> > icmp_ln65_fu_480_p2; sc_signal< sc_logic > data_V_data_1_V_blk_n; sc_signal< sc_logic > data_V_data_2_V_blk_n; sc_signal< sc_logic > data_V_data_3_V_blk_n; sc_signal< sc_logic > data_V_data_4_V_blk_n; sc_signal< sc_logic > data_V_data_5_V_blk_n; sc_signal< sc_logic > data_V_data_6_V_blk_n; sc_signal< sc_logic > data_V_data_7_V_blk_n; sc_signal< sc_logic > data_V_data_8_V_blk_n; sc_signal< sc_logic > data_V_data_9_V_blk_n; sc_signal< sc_logic > data_V_data_10_V_blk_n; sc_signal< sc_logic > data_V_data_11_V_blk_n; sc_signal< sc_logic > data_V_data_12_V_blk_n; sc_signal< sc_logic > data_V_data_13_V_blk_n; sc_signal< sc_logic > data_V_data_14_V_blk_n; sc_signal< sc_logic > data_V_data_15_V_blk_n; sc_signal< sc_logic > data_V_data_16_V_blk_n; sc_signal< sc_logic > data_V_data_17_V_blk_n; sc_signal< sc_logic > data_V_data_18_V_blk_n; sc_signal< sc_logic > data_V_data_19_V_blk_n; sc_signal< sc_logic > data_V_data_20_V_blk_n; sc_signal< sc_logic > data_V_data_21_V_blk_n; sc_signal< sc_logic > data_V_data_22_V_blk_n; sc_signal< sc_logic > data_V_data_23_V_blk_n; sc_signal< sc_logic > data_V_data_24_V_blk_n; sc_signal< sc_logic > data_V_data_25_V_blk_n; sc_signal< sc_logic > data_V_data_26_V_blk_n; sc_signal< sc_logic > data_V_data_27_V_blk_n; sc_signal< sc_logic > data_V_data_28_V_blk_n; sc_signal< sc_logic > data_V_data_29_V_blk_n; sc_signal< sc_logic > data_V_data_30_V_blk_n; sc_signal< sc_logic > data_V_data_31_V_blk_n; sc_signal< sc_logic > res_V_data_0_V_blk_n; sc_signal< sc_logic > ap_CS_fsm_state2; sc_signal< sc_lv<1> > icmp_ln56_fu_456_p2; sc_signal< sc_logic > ap_CS_fsm_state3; sc_signal< sc_lv<1> > icmp_ln61_fu_468_p2; sc_signal< sc_logic > ap_CS_fsm_state5; sc_signal< sc_lv<1> > icmp_ln68_fu_652_p2; sc_signal< sc_logic > ap_CS_fsm_state7; sc_signal< sc_lv<1> > icmp_ln74_fu_676_p2; sc_signal< sc_logic > res_V_data_1_V_blk_n; sc_signal< sc_logic > res_V_data_2_V_blk_n; sc_signal< sc_logic > res_V_data_3_V_blk_n; sc_signal< sc_logic > res_V_data_4_V_blk_n; sc_signal< sc_logic > res_V_data_5_V_blk_n; sc_signal< sc_logic > res_V_data_6_V_blk_n; sc_signal< sc_logic > res_V_data_7_V_blk_n; sc_signal< sc_logic > res_V_data_8_V_blk_n; sc_signal< sc_logic > res_V_data_9_V_blk_n; sc_signal< sc_logic > res_V_data_10_V_blk_n; sc_signal< sc_logic > res_V_data_11_V_blk_n; sc_signal< sc_logic > res_V_data_12_V_blk_n; sc_signal< sc_logic > res_V_data_13_V_blk_n; sc_signal< sc_logic > res_V_data_14_V_blk_n; sc_signal< sc_logic > res_V_data_15_V_blk_n; sc_signal< sc_logic > res_V_data_16_V_blk_n; sc_signal< sc_logic > res_V_data_17_V_blk_n; sc_signal< sc_logic > res_V_data_18_V_blk_n; sc_signal< sc_logic > res_V_data_19_V_blk_n; sc_signal< sc_logic > res_V_data_20_V_blk_n; sc_signal< sc_logic > res_V_data_21_V_blk_n; sc_signal< sc_logic > res_V_data_22_V_blk_n; sc_signal< sc_logic > res_V_data_23_V_blk_n; sc_signal< sc_logic > res_V_data_24_V_blk_n; sc_signal< sc_logic > res_V_data_25_V_blk_n; sc_signal< sc_logic > res_V_data_26_V_blk_n; sc_signal< sc_logic > res_V_data_27_V_blk_n; sc_signal< sc_logic > res_V_data_28_V_blk_n; sc_signal< sc_logic > res_V_data_29_V_blk_n; sc_signal< sc_logic > res_V_data_30_V_blk_n; sc_signal< sc_logic > res_V_data_31_V_blk_n; sc_signal< sc_lv<6> > j_fu_462_p2; sc_signal< sc_logic > io_acc_block_signal_op81; sc_signal< bool > ap_block_state2; sc_signal< sc_lv<6> > i_3_fu_474_p2; sc_signal< sc_lv<6> > i_3_reg_699; sc_signal< sc_logic > io_acc_block_signal_op93; sc_signal< bool > ap_block_state3; sc_signal< sc_lv<6> > j_7_fu_486_p2; sc_signal< sc_logic > io_acc_block_signal_op102; sc_signal< sc_logic > io_acc_block_signal_op135; sc_signal< bool > ap_block_state4; sc_signal< sc_lv<2> > j_9_fu_658_p2; sc_signal< sc_logic > io_acc_block_signal_op144; sc_signal< bool > ap_block_state5; sc_signal< sc_lv<2> > i_fu_670_p2; sc_signal< sc_lv<2> > i_reg_723; sc_signal< sc_logic > ap_CS_fsm_state6; sc_signal< sc_lv<6> > j_8_fu_682_p2; sc_signal< sc_logic > io_acc_block_signal_op163; sc_signal< bool > ap_block_state7; sc_signal< sc_lv<6> > j_0_reg_390; sc_signal< bool > ap_block_state1; sc_signal< sc_lv<6> > i1_0_reg_401; sc_signal< sc_lv<6> > j3_0_reg_412; sc_signal< sc_lv<2> > j4_0_reg_423; sc_signal< sc_lv<2> > i5_0_reg_434; sc_signal< sc_lv<6> > j6_0_reg_445; sc_signal< sc_lv<1> > icmp_ln73_fu_664_p2; sc_signal< sc_lv<7> > ap_NS_fsm; static const sc_logic ap_const_logic_1; static const sc_logic ap_const_logic_0; static const sc_lv<7> ap_ST_fsm_state1; static const sc_lv<7> ap_ST_fsm_state2; static const sc_lv<7> ap_ST_fsm_state3; static const sc_lv<7> ap_ST_fsm_state4; static const sc_lv<7> ap_ST_fsm_state5; static const sc_lv<7> ap_ST_fsm_state6; static const sc_lv<7> ap_ST_fsm_state7; static const sc_lv<32> ap_const_lv32_0; static const sc_lv<32> ap_const_lv32_3; static const sc_lv<1> ap_const_lv1_0; static const sc_lv<32> ap_const_lv32_1; static const sc_lv<32> ap_const_lv32_2; static const sc_lv<32> ap_const_lv32_4; static const sc_lv<32> ap_const_lv32_6; static const sc_lv<32> ap_const_lv32_5; static const sc_lv<6> ap_const_lv6_0; static const sc_lv<1> ap_const_lv1_1; static const sc_lv<2> ap_const_lv2_0; static const sc_lv<8> ap_const_lv8_0; static const sc_lv<6> ap_const_lv6_23; static const sc_lv<6> ap_const_lv6_1; static const sc_lv<6> ap_const_lv6_20; static const sc_lv<2> ap_const_lv2_2; static const sc_lv<2> ap_const_lv2_1; static const bool ap_const_boolean_1; // Thread declarations void thread_ap_clk_no_reset_(); void thread_ap_CS_fsm_state1(); void thread_ap_CS_fsm_state2(); void thread_ap_CS_fsm_state3(); void thread_ap_CS_fsm_state4(); void thread_ap_CS_fsm_state5(); void thread_ap_CS_fsm_state6(); void thread_ap_CS_fsm_state7(); void thread_ap_block_state1(); void thread_ap_block_state2(); void thread_ap_block_state3(); void thread_ap_block_state4(); void thread_ap_block_state5(); void thread_ap_block_state7(); void thread_ap_done(); void thread_ap_idle(); void thread_ap_ready(); void thread_data_V_data_0_V_blk_n(); void thread_data_V_data_0_V_read(); void thread_data_V_data_10_V_blk_n(); void thread_data_V_data_10_V_read(); void thread_data_V_data_11_V_blk_n(); void thread_data_V_data_11_V_read(); void thread_data_V_data_12_V_blk_n(); void thread_data_V_data_12_V_read(); void thread_data_V_data_13_V_blk_n(); void thread_data_V_data_13_V_read(); void thread_data_V_data_14_V_blk_n(); void thread_data_V_data_14_V_read(); void thread_data_V_data_15_V_blk_n(); void thread_data_V_data_15_V_read(); void thread_data_V_data_16_V_blk_n(); void thread_data_V_data_16_V_read(); void thread_data_V_data_17_V_blk_n(); void thread_data_V_data_17_V_read(); void thread_data_V_data_18_V_blk_n(); void thread_data_V_data_18_V_read(); void thread_data_V_data_19_V_blk_n(); void thread_data_V_data_19_V_read(); void thread_data_V_data_1_V_blk_n(); void thread_data_V_data_1_V_read(); void thread_data_V_data_20_V_blk_n(); void thread_data_V_data_20_V_read(); void thread_data_V_data_21_V_blk_n(); void thread_data_V_data_21_V_read(); void thread_data_V_data_22_V_blk_n(); void thread_data_V_data_22_V_read(); void thread_data_V_data_23_V_blk_n(); void thread_data_V_data_23_V_read(); void thread_data_V_data_24_V_blk_n(); void thread_data_V_data_24_V_read(); void thread_data_V_data_25_V_blk_n(); void thread_data_V_data_25_V_read(); void thread_data_V_data_26_V_blk_n(); void thread_data_V_data_26_V_read(); void thread_data_V_data_27_V_blk_n(); void thread_data_V_data_27_V_read(); void thread_data_V_data_28_V_blk_n(); void thread_data_V_data_28_V_read(); void thread_data_V_data_29_V_blk_n(); void thread_data_V_data_29_V_read(); void thread_data_V_data_2_V_blk_n(); void thread_data_V_data_2_V_read(); void thread_data_V_data_30_V_blk_n(); void thread_data_V_data_30_V_read(); void thread_data_V_data_31_V_blk_n(); void thread_data_V_data_31_V_read(); void thread_data_V_data_3_V_blk_n(); void thread_data_V_data_3_V_read(); void thread_data_V_data_4_V_blk_n(); void thread_data_V_data_4_V_read(); void thread_data_V_data_5_V_blk_n(); void thread_data_V_data_5_V_read(); void thread_data_V_data_6_V_blk_n(); void thread_data_V_data_6_V_read(); void thread_data_V_data_7_V_blk_n(); void thread_data_V_data_7_V_read(); void thread_data_V_data_8_V_blk_n(); void thread_data_V_data_8_V_read(); void thread_data_V_data_9_V_blk_n(); void thread_data_V_data_9_V_read(); void thread_i_3_fu_474_p2(); void thread_i_fu_670_p2(); void thread_icmp_ln56_fu_456_p2(); void thread_icmp_ln61_fu_468_p2(); void thread_icmp_ln65_fu_480_p2(); void thread_icmp_ln68_fu_652_p2(); void thread_icmp_ln73_fu_664_p2(); void thread_icmp_ln74_fu_676_p2(); void thread_internal_ap_ready(); void thread_io_acc_block_signal_op102(); void thread_io_acc_block_signal_op135(); void thread_io_acc_block_signal_op144(); void thread_io_acc_block_signal_op163(); void thread_io_acc_block_signal_op81(); void thread_io_acc_block_signal_op93(); void thread_j_7_fu_486_p2(); void thread_j_8_fu_682_p2(); void thread_j_9_fu_658_p2(); void thread_j_fu_462_p2(); void thread_real_start(); void thread_res_V_data_0_V_blk_n(); void thread_res_V_data_0_V_din(); void thread_res_V_data_0_V_write(); void thread_res_V_data_10_V_blk_n(); void thread_res_V_data_10_V_din(); void thread_res_V_data_10_V_write(); void thread_res_V_data_11_V_blk_n(); void thread_res_V_data_11_V_din(); void thread_res_V_data_11_V_write(); void thread_res_V_data_12_V_blk_n(); void thread_res_V_data_12_V_din(); void thread_res_V_data_12_V_write(); void thread_res_V_data_13_V_blk_n(); void thread_res_V_data_13_V_din(); void thread_res_V_data_13_V_write(); void thread_res_V_data_14_V_blk_n(); void thread_res_V_data_14_V_din(); void thread_res_V_data_14_V_write(); void thread_res_V_data_15_V_blk_n(); void thread_res_V_data_15_V_din(); void thread_res_V_data_15_V_write(); void thread_res_V_data_16_V_blk_n(); void thread_res_V_data_16_V_din(); void thread_res_V_data_16_V_write(); void thread_res_V_data_17_V_blk_n(); void thread_res_V_data_17_V_din(); void thread_res_V_data_17_V_write(); void thread_res_V_data_18_V_blk_n(); void thread_res_V_data_18_V_din(); void thread_res_V_data_18_V_write(); void thread_res_V_data_19_V_blk_n(); void thread_res_V_data_19_V_din(); void thread_res_V_data_19_V_write(); void thread_res_V_data_1_V_blk_n(); void thread_res_V_data_1_V_din(); void thread_res_V_data_1_V_write(); void thread_res_V_data_20_V_blk_n(); void thread_res_V_data_20_V_din(); void thread_res_V_data_20_V_write(); void thread_res_V_data_21_V_blk_n(); void thread_res_V_data_21_V_din(); void thread_res_V_data_21_V_write(); void thread_res_V_data_22_V_blk_n(); void thread_res_V_data_22_V_din(); void thread_res_V_data_22_V_write(); void thread_res_V_data_23_V_blk_n(); void thread_res_V_data_23_V_din(); void thread_res_V_data_23_V_write(); void thread_res_V_data_24_V_blk_n(); void thread_res_V_data_24_V_din(); void thread_res_V_data_24_V_write(); void thread_res_V_data_25_V_blk_n(); void thread_res_V_data_25_V_din(); void thread_res_V_data_25_V_write(); void thread_res_V_data_26_V_blk_n(); void thread_res_V_data_26_V_din(); void thread_res_V_data_26_V_write(); void thread_res_V_data_27_V_blk_n(); void thread_res_V_data_27_V_din(); void thread_res_V_data_27_V_write(); void thread_res_V_data_28_V_blk_n(); void thread_res_V_data_28_V_din(); void thread_res_V_data_28_V_write(); void thread_res_V_data_29_V_blk_n(); void thread_res_V_data_29_V_din(); void thread_res_V_data_29_V_write(); void thread_res_V_data_2_V_blk_n(); void thread_res_V_data_2_V_din(); void thread_res_V_data_2_V_write(); void thread_res_V_data_30_V_blk_n(); void thread_res_V_data_30_V_din(); void thread_res_V_data_30_V_write(); void thread_res_V_data_31_V_blk_n(); void thread_res_V_data_31_V_din(); void thread_res_V_data_31_V_write(); void thread_res_V_data_3_V_blk_n(); void thread_res_V_data_3_V_din(); void thread_res_V_data_3_V_write(); void thread_res_V_data_4_V_blk_n(); void thread_res_V_data_4_V_din(); void thread_res_V_data_4_V_write(); void thread_res_V_data_5_V_blk_n(); void thread_res_V_data_5_V_din(); void thread_res_V_data_5_V_write(); void thread_res_V_data_6_V_blk_n(); void thread_res_V_data_6_V_din(); void thread_res_V_data_6_V_write(); void thread_res_V_data_7_V_blk_n(); void thread_res_V_data_7_V_din(); void thread_res_V_data_7_V_write(); void thread_res_V_data_8_V_blk_n(); void thread_res_V_data_8_V_din(); void thread_res_V_data_8_V_write(); void thread_res_V_data_9_V_blk_n(); void thread_res_V_data_9_V_din(); void thread_res_V_data_9_V_write(); void thread_start_out(); void thread_start_write(); void thread_ap_NS_fsm(); }; } using namespace ap_rtl; #endif
41.987826
80
0.752475
63cd49d0c1434b8cb746b1f6eac70f8fb6d75ae1
18,626
c
C
src/asn/rrc/ASN_RRC_PhysicalCellGroupConfig.c
aligungr/ue-ran-sim
564f9d228723f03adfa2b02df2ea019bdf305085
[ "MIT" ]
16
2020-04-16T02:07:37.000Z
2020-07-23T10:48:27.000Z
src/asn/rrc/ASN_RRC_PhysicalCellGroupConfig.c
aligungr/ue-ran-sim
564f9d228723f03adfa2b02df2ea019bdf305085
[ "MIT" ]
8
2020-07-13T17:11:35.000Z
2020-08-03T16:46:31.000Z
src/asn/rrc/ASN_RRC_PhysicalCellGroupConfig.c
aligungr/ue-ran-sim
564f9d228723f03adfa2b02df2ea019bdf305085
[ "MIT" ]
9
2020-03-04T15:05:08.000Z
2020-07-30T06:18:18.000Z
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "NR-RRC-Definitions" * found in "asn/nr-rrc-15.6.0.asn1" * `asn1c -fcompound-names -pdu=all -findirect-choice -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D rrc` */ #include "ASN_RRC_PhysicalCellGroupConfig.h" #include "ASN_RRC_SetupRelease.h" /* * This type is implemented using NativeEnumerated, * so here we adjust the DEF accordingly. */ /* * This type is implemented using NativeEnumerated, * so here we adjust the DEF accordingly. */ /* * This type is implemented using NativeEnumerated, * so here we adjust the DEF accordingly. */ /* * This type is implemented using NativeEnumerated, * so here we adjust the DEF accordingly. */ static asn_per_constraints_t asn_PER_type_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_constr_2 CC_NOTUSED = { { APC_CONSTRAINED, 0, 0, 0, 0 } /* (0..0) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; static asn_per_constraints_t asn_PER_type_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_constr_4 CC_NOTUSED = { { APC_CONSTRAINED, 0, 0, 0, 0 } /* (0..0) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; static asn_per_constraints_t asn_PER_type_ASN_RRC_pdsch_HARQ_ACK_Codebook_constr_7 CC_NOTUSED = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; static asn_per_constraints_t asn_PER_type_ASN_RRC_xScale_constr_20 CC_NOTUSED = { { APC_CONSTRAINED, 2, 2, 0, 3 } /* (0..3) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; static const asn_INTEGER_enum_map_t asn_MAP_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_value2enum_2[] = { { 0, 4, "true" } }; static const unsigned int asn_MAP_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_enum2value_2[] = { 0 /* true(0) */ }; static const asn_INTEGER_specifics_t asn_SPC_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_specs_2 = { asn_MAP_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_value2enum_2, /* "tag" => N; sorted by tag */ asn_MAP_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_enum2value_2, /* N => "tag"; sorted by N */ 1, /* Number of elements in the maps */ 0, /* Enumeration is not extensible */ 1, /* Strict enumeration */ 0, /* Native long size */ 0 }; static const ber_tlv_tag_t asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_tags_2[] = { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_2 = { "harq-ACK-SpatialBundlingPUCCH", "harq-ACK-SpatialBundlingPUCCH", &asn_OP_NativeEnumerated, asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_tags_2, sizeof(asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_tags_2) /sizeof(asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_tags_2[0]) - 1, /* 1 */ asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_tags_2, /* Same as above */ sizeof(asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_tags_2) /sizeof(asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_tags_2[0]), /* 2 */ { 0, &asn_PER_type_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_constr_2, NativeEnumerated_constraint }, 0, 0, /* Defined elsewhere */ &asn_SPC_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_specs_2 /* Additional specs */ }; static const asn_INTEGER_enum_map_t asn_MAP_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_value2enum_4[] = { { 0, 4, "true" } }; static const unsigned int asn_MAP_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_enum2value_4[] = { 0 /* true(0) */ }; static const asn_INTEGER_specifics_t asn_SPC_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_specs_4 = { asn_MAP_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_value2enum_4, /* "tag" => N; sorted by tag */ asn_MAP_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_enum2value_4, /* N => "tag"; sorted by N */ 1, /* Number of elements in the maps */ 0, /* Enumeration is not extensible */ 1, /* Strict enumeration */ 0, /* Native long size */ 0 }; static const ber_tlv_tag_t asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_tags_4[] = { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_4 = { "harq-ACK-SpatialBundlingPUSCH", "harq-ACK-SpatialBundlingPUSCH", &asn_OP_NativeEnumerated, asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_tags_4, sizeof(asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_tags_4) /sizeof(asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_tags_4[0]) - 1, /* 1 */ asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_tags_4, /* Same as above */ sizeof(asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_tags_4) /sizeof(asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_tags_4[0]), /* 2 */ { 0, &asn_PER_type_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_constr_4, NativeEnumerated_constraint }, 0, 0, /* Defined elsewhere */ &asn_SPC_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_specs_4 /* Additional specs */ }; static const asn_INTEGER_enum_map_t asn_MAP_ASN_RRC_pdsch_HARQ_ACK_Codebook_value2enum_7[] = { { 0, 10, "semiStatic" }, { 1, 7, "dynamic" } }; static const unsigned int asn_MAP_ASN_RRC_pdsch_HARQ_ACK_Codebook_enum2value_7[] = { 1, /* dynamic(1) */ 0 /* semiStatic(0) */ }; static const asn_INTEGER_specifics_t asn_SPC_ASN_RRC_pdsch_HARQ_ACK_Codebook_specs_7 = { asn_MAP_ASN_RRC_pdsch_HARQ_ACK_Codebook_value2enum_7, /* "tag" => N; sorted by tag */ asn_MAP_ASN_RRC_pdsch_HARQ_ACK_Codebook_enum2value_7, /* N => "tag"; sorted by N */ 2, /* Number of elements in the maps */ 0, /* Enumeration is not extensible */ 1, /* Strict enumeration */ 0, /* Native long size */ 0 }; static const ber_tlv_tag_t asn_DEF_ASN_RRC_pdsch_HARQ_ACK_Codebook_tags_7[] = { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_ASN_RRC_pdsch_HARQ_ACK_Codebook_7 = { "pdsch-HARQ-ACK-Codebook", "pdsch-HARQ-ACK-Codebook", &asn_OP_NativeEnumerated, asn_DEF_ASN_RRC_pdsch_HARQ_ACK_Codebook_tags_7, sizeof(asn_DEF_ASN_RRC_pdsch_HARQ_ACK_Codebook_tags_7) /sizeof(asn_DEF_ASN_RRC_pdsch_HARQ_ACK_Codebook_tags_7[0]) - 1, /* 1 */ asn_DEF_ASN_RRC_pdsch_HARQ_ACK_Codebook_tags_7, /* Same as above */ sizeof(asn_DEF_ASN_RRC_pdsch_HARQ_ACK_Codebook_tags_7) /sizeof(asn_DEF_ASN_RRC_pdsch_HARQ_ACK_Codebook_tags_7[0]), /* 2 */ { 0, &asn_PER_type_ASN_RRC_pdsch_HARQ_ACK_Codebook_constr_7, NativeEnumerated_constraint }, 0, 0, /* Defined elsewhere */ &asn_SPC_ASN_RRC_pdsch_HARQ_ACK_Codebook_specs_7 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_ASN_RRC_ext1_16[] = { { ATF_POINTER, 2, offsetof(struct ASN_RRC_PhysicalCellGroupConfig__ext1, mcs_C_RNTI), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_RNTI_Value, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "mcs-C-RNTI" }, { ATF_POINTER, 1, offsetof(struct ASN_RRC_PhysicalCellGroupConfig__ext1, p_UE_FR1), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_P_Max, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "p-UE-FR1" }, }; static const int asn_MAP_ASN_RRC_ext1_oms_16[] = { 0, 1 }; static const ber_tlv_tag_t asn_DEF_ASN_RRC_ext1_tags_16[] = { (ASN_TAG_CLASS_CONTEXT | (9 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static const asn_TYPE_tag2member_t asn_MAP_ASN_RRC_ext1_tag2el_16[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* mcs-C-RNTI */ { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* p-UE-FR1 */ }; static asn_SEQUENCE_specifics_t asn_SPC_ASN_RRC_ext1_specs_16 = { sizeof(struct ASN_RRC_PhysicalCellGroupConfig__ext1), offsetof(struct ASN_RRC_PhysicalCellGroupConfig__ext1, _asn_ctx), asn_MAP_ASN_RRC_ext1_tag2el_16, 2, /* Count of tags in the map */ asn_MAP_ASN_RRC_ext1_oms_16, /* Optional members */ 2, 0, /* Root/Additions */ -1, /* First extension addition */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_ASN_RRC_ext1_16 = { "ext1", "ext1", &asn_OP_SEQUENCE, asn_DEF_ASN_RRC_ext1_tags_16, sizeof(asn_DEF_ASN_RRC_ext1_tags_16) /sizeof(asn_DEF_ASN_RRC_ext1_tags_16[0]) - 1, /* 1 */ asn_DEF_ASN_RRC_ext1_tags_16, /* Same as above */ sizeof(asn_DEF_ASN_RRC_ext1_tags_16) /sizeof(asn_DEF_ASN_RRC_ext1_tags_16[0]), /* 2 */ { 0, 0, SEQUENCE_constraint }, asn_MBR_ASN_RRC_ext1_16, 2, /* Elements count */ &asn_SPC_ASN_RRC_ext1_specs_16 /* Additional specs */ }; static const asn_INTEGER_enum_map_t asn_MAP_ASN_RRC_xScale_value2enum_20[] = { { 0, 3, "dB0" }, { 1, 3, "dB6" }, { 2, 6, "spare2" }, { 3, 6, "spare1" } }; static const unsigned int asn_MAP_ASN_RRC_xScale_enum2value_20[] = { 0, /* dB0(0) */ 1, /* dB6(1) */ 3, /* spare1(3) */ 2 /* spare2(2) */ }; static const asn_INTEGER_specifics_t asn_SPC_ASN_RRC_xScale_specs_20 = { asn_MAP_ASN_RRC_xScale_value2enum_20, /* "tag" => N; sorted by tag */ asn_MAP_ASN_RRC_xScale_enum2value_20, /* N => "tag"; sorted by N */ 4, /* Number of elements in the maps */ 0, /* Enumeration is not extensible */ 1, /* Strict enumeration */ 0, /* Native long size */ 0 }; static const ber_tlv_tag_t asn_DEF_ASN_RRC_xScale_tags_20[] = { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_ASN_RRC_xScale_20 = { "xScale", "xScale", &asn_OP_NativeEnumerated, asn_DEF_ASN_RRC_xScale_tags_20, sizeof(asn_DEF_ASN_RRC_xScale_tags_20) /sizeof(asn_DEF_ASN_RRC_xScale_tags_20[0]) - 1, /* 1 */ asn_DEF_ASN_RRC_xScale_tags_20, /* Same as above */ sizeof(asn_DEF_ASN_RRC_xScale_tags_20) /sizeof(asn_DEF_ASN_RRC_xScale_tags_20[0]), /* 2 */ { 0, &asn_PER_type_ASN_RRC_xScale_constr_20, NativeEnumerated_constraint }, 0, 0, /* Defined elsewhere */ &asn_SPC_ASN_RRC_xScale_specs_20 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_ASN_RRC_ext2_19[] = { { ATF_POINTER, 1, offsetof(struct ASN_RRC_PhysicalCellGroupConfig__ext2, xScale), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_xScale_20, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "xScale" }, }; static const int asn_MAP_ASN_RRC_ext2_oms_19[] = { 0 }; static const ber_tlv_tag_t asn_DEF_ASN_RRC_ext2_tags_19[] = { (ASN_TAG_CLASS_CONTEXT | (10 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static const asn_TYPE_tag2member_t asn_MAP_ASN_RRC_ext2_tag2el_19[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* xScale */ }; static asn_SEQUENCE_specifics_t asn_SPC_ASN_RRC_ext2_specs_19 = { sizeof(struct ASN_RRC_PhysicalCellGroupConfig__ext2), offsetof(struct ASN_RRC_PhysicalCellGroupConfig__ext2, _asn_ctx), asn_MAP_ASN_RRC_ext2_tag2el_19, 1, /* Count of tags in the map */ asn_MAP_ASN_RRC_ext2_oms_19, /* Optional members */ 1, 0, /* Root/Additions */ -1, /* First extension addition */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_ASN_RRC_ext2_19 = { "ext2", "ext2", &asn_OP_SEQUENCE, asn_DEF_ASN_RRC_ext2_tags_19, sizeof(asn_DEF_ASN_RRC_ext2_tags_19) /sizeof(asn_DEF_ASN_RRC_ext2_tags_19[0]) - 1, /* 1 */ asn_DEF_ASN_RRC_ext2_tags_19, /* Same as above */ sizeof(asn_DEF_ASN_RRC_ext2_tags_19) /sizeof(asn_DEF_ASN_RRC_ext2_tags_19[0]), /* 2 */ { 0, 0, SEQUENCE_constraint }, asn_MBR_ASN_RRC_ext2_19, 1, /* Elements count */ &asn_SPC_ASN_RRC_ext2_specs_19 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_ASN_RRC_ext3_25[] = { { ATF_POINTER, 1, offsetof(struct ASN_RRC_PhysicalCellGroupConfig__ext3, pdcch_BlindDetection), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ASN_RRC_SetupRelease_PDCCH_BlindDetection, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "pdcch-BlindDetection" }, }; static const int asn_MAP_ASN_RRC_ext3_oms_25[] = { 0 }; static const ber_tlv_tag_t asn_DEF_ASN_RRC_ext3_tags_25[] = { (ASN_TAG_CLASS_CONTEXT | (11 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static const asn_TYPE_tag2member_t asn_MAP_ASN_RRC_ext3_tag2el_25[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* pdcch-BlindDetection */ }; static asn_SEQUENCE_specifics_t asn_SPC_ASN_RRC_ext3_specs_25 = { sizeof(struct ASN_RRC_PhysicalCellGroupConfig__ext3), offsetof(struct ASN_RRC_PhysicalCellGroupConfig__ext3, _asn_ctx), asn_MAP_ASN_RRC_ext3_tag2el_25, 1, /* Count of tags in the map */ asn_MAP_ASN_RRC_ext3_oms_25, /* Optional members */ 1, 0, /* Root/Additions */ -1, /* First extension addition */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_ASN_RRC_ext3_25 = { "ext3", "ext3", &asn_OP_SEQUENCE, asn_DEF_ASN_RRC_ext3_tags_25, sizeof(asn_DEF_ASN_RRC_ext3_tags_25) /sizeof(asn_DEF_ASN_RRC_ext3_tags_25[0]) - 1, /* 1 */ asn_DEF_ASN_RRC_ext3_tags_25, /* Same as above */ sizeof(asn_DEF_ASN_RRC_ext3_tags_25) /sizeof(asn_DEF_ASN_RRC_ext3_tags_25[0]), /* 2 */ { 0, 0, SEQUENCE_constraint }, asn_MBR_ASN_RRC_ext3_25, 1, /* Elements count */ &asn_SPC_ASN_RRC_ext3_specs_25 /* Additional specs */ }; asn_TYPE_member_t asn_MBR_ASN_RRC_PhysicalCellGroupConfig_1[] = { { ATF_POINTER, 3, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, harq_ACK_SpatialBundlingPUCCH), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUCCH_2, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "harq-ACK-SpatialBundlingPUCCH" }, { ATF_POINTER, 2, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, harq_ACK_SpatialBundlingPUSCH), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_harq_ACK_SpatialBundlingPUSCH_4, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "harq-ACK-SpatialBundlingPUSCH" }, { ATF_POINTER, 1, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, p_NR_FR1), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_P_Max, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "p-NR-FR1" }, { ATF_NOFLAGS, 0, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, pdsch_HARQ_ACK_Codebook), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_pdsch_HARQ_ACK_Codebook_7, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "pdsch-HARQ-ACK-Codebook" }, { ATF_POINTER, 8, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, tpc_SRS_RNTI), (ASN_TAG_CLASS_CONTEXT | (4 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_RNTI_Value, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "tpc-SRS-RNTI" }, { ATF_POINTER, 7, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, tpc_PUCCH_RNTI), (ASN_TAG_CLASS_CONTEXT | (5 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_RNTI_Value, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "tpc-PUCCH-RNTI" }, { ATF_POINTER, 6, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, tpc_PUSCH_RNTI), (ASN_TAG_CLASS_CONTEXT | (6 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_RNTI_Value, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "tpc-PUSCH-RNTI" }, { ATF_POINTER, 5, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, sp_CSI_RNTI), (ASN_TAG_CLASS_CONTEXT | (7 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_ASN_RRC_RNTI_Value, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "sp-CSI-RNTI" }, { ATF_POINTER, 4, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, cs_RNTI), (ASN_TAG_CLASS_CONTEXT | (8 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_ASN_RRC_SetupRelease_RNTI_Value, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "cs-RNTI" }, { ATF_POINTER, 3, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, ext1), (ASN_TAG_CLASS_CONTEXT | (9 << 2)), 0, &asn_DEF_ASN_RRC_ext1_16, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "ext1" }, { ATF_POINTER, 2, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, ext2), (ASN_TAG_CLASS_CONTEXT | (10 << 2)), 0, &asn_DEF_ASN_RRC_ext2_19, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "ext2" }, { ATF_POINTER, 1, offsetof(struct ASN_RRC_PhysicalCellGroupConfig, ext3), (ASN_TAG_CLASS_CONTEXT | (11 << 2)), 0, &asn_DEF_ASN_RRC_ext3_25, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "ext3" }, }; static const int asn_MAP_ASN_RRC_PhysicalCellGroupConfig_oms_1[] = { 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11 }; static const ber_tlv_tag_t asn_DEF_ASN_RRC_PhysicalCellGroupConfig_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static const asn_TYPE_tag2member_t asn_MAP_ASN_RRC_PhysicalCellGroupConfig_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* harq-ACK-SpatialBundlingPUCCH */ { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* harq-ACK-SpatialBundlingPUSCH */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* p-NR-FR1 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* pdsch-HARQ-ACK-Codebook */ { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 }, /* tpc-SRS-RNTI */ { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0 }, /* tpc-PUCCH-RNTI */ { (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 6, 0, 0 }, /* tpc-PUSCH-RNTI */ { (ASN_TAG_CLASS_CONTEXT | (7 << 2)), 7, 0, 0 }, /* sp-CSI-RNTI */ { (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 8, 0, 0 }, /* cs-RNTI */ { (ASN_TAG_CLASS_CONTEXT | (9 << 2)), 9, 0, 0 }, /* ext1 */ { (ASN_TAG_CLASS_CONTEXT | (10 << 2)), 10, 0, 0 }, /* ext2 */ { (ASN_TAG_CLASS_CONTEXT | (11 << 2)), 11, 0, 0 } /* ext3 */ }; asn_SEQUENCE_specifics_t asn_SPC_ASN_RRC_PhysicalCellGroupConfig_specs_1 = { sizeof(struct ASN_RRC_PhysicalCellGroupConfig), offsetof(struct ASN_RRC_PhysicalCellGroupConfig, _asn_ctx), asn_MAP_ASN_RRC_PhysicalCellGroupConfig_tag2el_1, 12, /* Count of tags in the map */ asn_MAP_ASN_RRC_PhysicalCellGroupConfig_oms_1, /* Optional members */ 8, 3, /* Root/Additions */ 9, /* First extension addition */ }; asn_TYPE_descriptor_t asn_DEF_ASN_RRC_PhysicalCellGroupConfig = { "PhysicalCellGroupConfig", "PhysicalCellGroupConfig", &asn_OP_SEQUENCE, asn_DEF_ASN_RRC_PhysicalCellGroupConfig_tags_1, sizeof(asn_DEF_ASN_RRC_PhysicalCellGroupConfig_tags_1) /sizeof(asn_DEF_ASN_RRC_PhysicalCellGroupConfig_tags_1[0]), /* 1 */ asn_DEF_ASN_RRC_PhysicalCellGroupConfig_tags_1, /* Same as above */ sizeof(asn_DEF_ASN_RRC_PhysicalCellGroupConfig_tags_1) /sizeof(asn_DEF_ASN_RRC_PhysicalCellGroupConfig_tags_1[0]), /* 1 */ { 0, 0, SEQUENCE_constraint }, asn_MBR_ASN_RRC_PhysicalCellGroupConfig_1, 12, /* Elements count */ &asn_SPC_ASN_RRC_PhysicalCellGroupConfig_specs_1 /* Additional specs */ };
37.780933
117
0.727317
4b44ca53ab6a87292a2f9fb279ab96d18010ca22
1,105
h
C
include/whole/algorithm/search.h
Lnk2past/whole
5a10d7d35b12f5e6850fd7d58404afa5aac2fcdc
[ "MIT" ]
1
2021-03-14T01:27:34.000Z
2021-03-14T01:27:34.000Z
include/whole/algorithm/search.h
Lnk2past/whole
5a10d7d35b12f5e6850fd7d58404afa5aac2fcdc
[ "MIT" ]
null
null
null
include/whole/algorithm/search.h
Lnk2past/whole
5a10d7d35b12f5e6850fd7d58404afa5aac2fcdc
[ "MIT" ]
null
null
null
#pragma once #include <algorithm> namespace whole { template< class Forward, class ForwardIt2 > constexpr auto search( Forward &one, ForwardIt2 s_first, ForwardIt2 s_last ) { return std::search(std::begin(one), std::end(one), s_first, s_last); } template< class Forward, class ForwardIt2, class BinaryPredicate > constexpr auto search( Forward &one, ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p ) { return std::search(std::begin(one), std::end(one), s_first, s_last, p); } template< class Forward, class Searcher > constexpr auto search( Forward &one, const Searcher& searcher ) { return std::search(std::begin(one), std::end(one), searcher); } template< class Forward, class Size, class T > constexpr auto search_n( Forward &one, Size count, const T& value ) { return std::search_n(std::begin(one), std::end(one), count, value); } template< class Forward, class Size, class T, class BinaryPredicate > constexpr auto search_n( Forward &one, Size count, const T& value, BinaryPredicate p ) { return std::search_n(std::begin(one), std::end(one), count, value, p); } }
29.078947
95
0.720362
af61f8710c67a959bde1d3b880d14ae92164f897
2,480
h
C
EasyCrossPlatform/XSYDMultiTask.h
BlueAirTechGroup/EasyCrossPlatform
8aa3c48767e17fb9a8dc41dbff6aa261705b018c
[ "MIT" ]
null
null
null
EasyCrossPlatform/XSYDMultiTask.h
BlueAirTechGroup/EasyCrossPlatform
8aa3c48767e17fb9a8dc41dbff6aa261705b018c
[ "MIT" ]
null
null
null
EasyCrossPlatform/XSYDMultiTask.h
BlueAirTechGroup/EasyCrossPlatform
8aa3c48767e17fb9a8dc41dbff6aa261705b018c
[ "MIT" ]
1
2018-03-25T11:43:29.000Z
2018-03-25T11:43:29.000Z
#ifndef __XSYDMultiTaskFile__ #define __XSYDMultiTaskFile__ #include "EasyCP_Common.h" #include <thread> #include <mutex> namespace EasyCrossPlatform { namespace Thread { typedef void (*SpecificWorkPtr)(std::thread::id ThreadID, void* Parameters, bool * RunningSign, std::mutex *Mutex); struct WorkInfo { SpecificWorkPtr MyWork; bool * RunningSign; std::mutex *mMutex; void * Parameters; }; class SingleWork { private: std::thread *mThread; bool RunningSign; SpecificWorkPtr MyWork; static int DoingJob(WorkInfo MyInfo); protected: public: SingleWork(SpecificWorkPtr mWork); SingleWork(SingleWork &mWork); bool StartJob(std::mutex *MyMutex = NULL, void* Parameter = NULL); void StopJob(); bool getRunningStatus(); ~SingleWork(); }; class SingleWorkCls { private: std::thread *mThread; std::mutex* TempMutex; void* TempParameter; bool RunningSign; static int DoingJob(SingleWorkCls* ClassPtr); protected: public: SingleWorkCls(); SingleWorkCls(SingleWorkCls &CopyWorkCls); bool StartJob(std::mutex* MyMutex = NULL, void* Parameters = NULL); void StopJob(); bool getRunningStatus(); virtual void ThreadJob(std::thread::id ThreadID, std::mutex* MyMutex = NULL, void* Parameters = NULL); ~SingleWorkCls(); }; struct WorkerInfo { SingleWork* wInfo; SingleWorkCls *wClsInfo; void* wParameters; }; struct WorksInfo { std::deque<WorkerInfo>* CurrentWorksAddr; std::deque<WorkerInfo>* PendingWorksAddr; unsigned int MaxThread; std::mutex *SharedMutex; std::mutex *LineMutex; }; class WorkPool { private: static void SuperviseThreads(std::thread::id ThreadID, void* Parameters, bool * RunningSign, std::mutex *Mutex); unsigned int MaxThread = 4; std::deque<WorkerInfo> CurrentWorks; std::deque <WorkerInfo> PendingWorks; std::mutex MyMutex; std::mutex LineMutex; SingleWork* SupervisingThread; bool Started; public: WorkPool(const unsigned int ThreadNum = 4); ~WorkPool(); void Start(); void Stop(); void addWork(SingleWork &MyWork, void* Parameter = NULL); void addWork(SingleWorkCls &MyWork, void* Parameter = NULL); void addWork_AtFront(SingleWork &MyWork, void* Parameter = NULL); void addWork_AtFront(SingleWorkCls &MyWork, void* Parameter = NULL); }; } } #endif
29.176471
118
0.670968
f4f9f9d650ad06dac2cfe4c2d9aabc8a92033877
900
c
C
code_source/SDL_jump.c
zeddo123/voidgame
4d247af542bf646c073c9445f36456e5a18c72e9
[ "MIT" ]
7
2019-02-12T15:37:44.000Z
2020-04-19T01:19:06.000Z
code_source/SDL_jump.c
zeddo123/voidgame
4d247af542bf646c073c9445f36456e5a18c72e9
[ "MIT" ]
null
null
null
code_source/SDL_jump.c
zeddo123/voidgame
4d247af542bf646c073c9445f36456e5a18c72e9
[ "MIT" ]
3
2019-03-29T18:12:09.000Z
2019-05-05T22:21:57.000Z
/** * @file SDL_jump.c * @brief save game * @author Kaisouneltahfoun * @version 0.5 * @date May 9,2019 */ //#include "SDL_jump.h" void jump(hero *player, SDL_Rect camera){ // Les variables lkol 7atithom random khatr naarach lmap mte3na kifeni SDL_Event event; SDL_PollEvent(&event); // Check to see if player is in the air if ( player->position.y + H < camera.y + ground_level ) { player->vel += 1; // Add gravity if he is } else { // Keep player from falling through the ground player->vel = 0; // put player_vely = -player_vely / 3; to make the player bounce off the ground :) player->position.y -= ground_level - H; } player->position.y += player->vel; // Add velocity to position if(event.type == SDL_KEYDOWN) { switch(event.key.keysym.sym) { case SDLK_SPACE: if ( player->position.y + H == ground_level ) player->vel = -8; break; } } }
20.930233
102
0.65
0ad168dec1a3f45d9aada8aa99d2cca97b9d4ee1
7,786
h
C
Samples/Browser/include/SampleBrowser_iOS.h
milram/ogre-1.7.4-osx
adec12bc0694b9b56a8f31e91cc72f0f75dd83c7
[ "MIT" ]
1
2015-07-09T17:45:20.000Z
2015-07-09T17:45:20.000Z
Samples/Browser/include/SampleBrowser_iOS.h
milram/ogre-1.7.4-osx
adec12bc0694b9b56a8f31e91cc72f0f75dd83c7
[ "MIT" ]
null
null
null
Samples/Browser/include/SampleBrowser_iOS.h
milram/ogre-1.7.4-osx
adec12bc0694b9b56a8f31e91cc72f0f75dd83c7
[ "MIT" ]
null
null
null
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2011 Torus Knot Software Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #ifndef __SampleBrowser_iOS_H__ #define __SampleBrowser_iOS_H__ #include "OgrePlatform.h" #if OGRE_PLATFORM != OGRE_PLATFORM_IPHONE #error This header is for use with iOS only #endif #import <UIKit/UIKit.h> #import <QuartzCore/QuartzCore.h> // To use CADisplayLink for smoother animation on iPhone comment out // the following line or define it to 1. Use with caution, it can // sometimes cause input lag. #define USE_CADISPLAYLINK 1 #ifdef __OBJC__ @interface AppDelegate : NSObject <UIApplicationDelegate> { NSTimer *mTimer; OgreBites::SampleBrowser sb; // Use of the CADisplayLink class is the preferred method for controlling your animation timing. // CADisplayLink will link to the main display and fire every vsync when added to a given run-loop. // The NSTimer class is used only as fallback when running on a pre 3.1 device where CADisplayLink // isn't available. id mDisplayLink; NSDate* mDate; NSTimeInterval mLastFrameTime; BOOL mDisplayLinkSupported; } - (void)go; - (void)renderOneFrame:(id)sender; - (void)orientationChanged:(NSNotification *)notification; @property (retain) NSTimer *mTimer; @property (nonatomic) NSTimeInterval mLastFrameTime; @end @implementation AppDelegate @synthesize mTimer; @dynamic mLastFrameTime; - (NSTimeInterval)mLastFrameTime { return mLastFrameTime; } - (void)setLastFrameTime:(NSTimeInterval)frameInterval { // Frame interval defines how many display frames must pass between each time the // display link fires. The display link will only fire 30 times a second when the // frame internal is two on a display that refreshes 60 times a second. The default // frame interval setting of one will fire 60 times a second when the display refreshes // at 60 times a second. A frame interval setting of less than one results in undefined // behavior. if (frameInterval >= 1) { mLastFrameTime = frameInterval; } } - (void)go { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; try { sb.go(); Ogre::Root::getSingleton().getRenderSystem()->_initRenderTargets(); // Clear event times Ogre::Root::getSingleton().clearEventTimes(); } catch( Ogre::Exception& e ) { std::cerr << "An exception has occurred: " << e.getFullDescription().c_str() << std::endl; } if (mDisplayLinkSupported) { // CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed // if the system version runtime check for CADisplayLink exists in -initWithCoder:. The runtime check ensures this code will // not be called in system versions earlier than 3.1. mDate = [[NSDate alloc] init]; mLastFrameTime = -[mDate timeIntervalSinceNow]; mDisplayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(renderOneFrame:)]; [mDisplayLink setFrameInterval:mLastFrameTime]; [mDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; } else { mTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)(1.0f / 60.0f) * mLastFrameTime target:self selector:@selector(renderOneFrame:) userInfo:nil repeats:YES]; } // Register for orientation notifications [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; [pool release]; } - (void)applicationDidFinishLaunching:(UIApplication *)application { // Hide the status bar [[UIApplication sharedApplication] setStatusBarHidden:YES]; mDisplayLinkSupported = FALSE; mLastFrameTime = 1; mDisplayLink = nil; mTimer = nil; // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer // class is used as fallback when it isn't available. #if USE_CADISPLAYLINK NSString *reqSysVer = @"3.1"; NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) mDisplayLinkSupported = TRUE; #endif [self go]; } - (void)applicationWillTerminate:(UIApplication *)application { Ogre::Root::getSingleton().queueEndRendering(); [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; if (mDisplayLinkSupported) { [mDate release]; mDate = nil; [mDisplayLink invalidate]; mDisplayLink = nil; } else { [mTimer invalidate]; mTimer = nil; } sb.shutdown(); } - (void)applicationWillResignActive:(UIApplication *)application { Ogre::Root::getSingleton().saveConfig(); [[NSNotificationCenter defaultCenter] removeObserver:self]; [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; } - (void)applicationDidBecomeActive:(UIApplication *)application { [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; } - (void)orientationChanged:(NSNotification *)notification { size_t v = 0; Ogre::Root::getSingleton().getAutoCreatedWindow()->getCustomAttribute("VIEW", &v); [(UIView *)v setNeedsLayout]; } - (void)renderOneFrame:(id)sender { [sb.mGestureView becomeFirstResponder]; if (mDisplayLinkSupported) { // NSTimerInterval is a simple typedef for double NSTimeInterval currentFrameTime = -[mDate timeIntervalSinceNow]; NSTimeInterval differenceInSeconds = currentFrameTime - mLastFrameTime; mLastFrameTime = currentFrameTime; Root::getSingleton().renderOneFrame((Real)differenceInSeconds); } else { Root::getSingleton().renderOneFrame((Real)[mTimer timeInterval]); } } @end #endif #endif
33.705628
136
0.686617
ebc9d7a211777ff7f57dd13848e88958601edefe
606
h
C
board/bk3633devkit/ble_config.h
bekencorp/bk3633_mesh_sdk
25cfde136043166193d12dafc935ab1d2c6d4e84
[ "Apache-2.0" ]
16
2020-09-08T09:58:40.000Z
2022-01-24T08:50:45.000Z
board/bk3633devkit/ble_config.h
bekencorp/bk3633_mesh_sdk
25cfde136043166193d12dafc935ab1d2c6d4e84
[ "Apache-2.0" ]
2
2020-11-17T07:45:03.000Z
2022-03-17T02:25:53.000Z
board/bk3633devkit/ble_config.h
bekencorp/bk3633_mesh_sdk
25cfde136043166193d12dafc935ab1d2c6d4e84
[ "Apache-2.0" ]
9
2020-08-05T09:48:31.000Z
2021-12-28T06:53:00.000Z
/* * Copyright (C) 2015-2017 Alibaba Group Holding Limited */ #ifndef BLE_CONFIG_H #define BLE_CONFIG_H #ifdef CONFIG_BT_MM_OPT #define CONFIG_BT_STATIC_THREAD_MAX_NUM 2 #else #define CONFIG_BT_STATIC_THREAD_MAX_NUM 5 #endif #define CONFIG_BT_HCI_TX_STACK_SIZE 500 + 100 #define CONFIG_BT_HCI_CMD_COUNT 2 #define CONFIG_BT_MAX_CONN 1 #if 0 #ifdef CONFIG_BLE_LINK_PARAMETERS #define CONFIG_SUP_TO_LIMIT 400 #define CONFIG_CONN_SUP_TIMEOUT 400 #define CONFIG_CONN_INTERVAL_MIN 24 #define CONFIG_CONN_INTERVAL_MAX 40 #endif #endif #if defined(__cplusplus) } #endif #endif /* BLE_DEF_CONFIG_H */
17.823529
56
0.815182
6f4995838fe1f60518fa5fd97d5c1f6903e6b2d9
1,628
h
C
uboot/u-boot-2010.06/product/hiosd/hdmi/godarm/eeprom.h
suda-morris/SUDA_3518E
cfad829ecd574ffe5e8c59c96ffad5c1e1bf5fa4
[ "Apache-2.0" ]
4
2020-04-28T02:12:34.000Z
2021-02-23T01:57:39.000Z
uboot/u-boot-2010.06/product/hiosd/hdmi/hi3535/eeprom.h
donginhb/SUDA_3518E
cfad829ecd574ffe5e8c59c96ffad5c1e1bf5fa4
[ "Apache-2.0" ]
null
null
null
uboot/u-boot-2010.06/product/hiosd/hdmi/hi3535/eeprom.h
donginhb/SUDA_3518E
cfad829ecd574ffe5e8c59c96ffad5c1e1bf5fa4
[ "Apache-2.0" ]
5
2018-05-16T16:36:08.000Z
2020-11-04T05:51:11.000Z
/***********************************************************************************/ /* Copyright (c) 2002-2006, Silicon Image, Inc. All rights reserved. */ /* No part of this work may be reproduced, modified, distributed, transmitted, */ /* transcribed, or translated into any language or computer format, in any form */ /* or by any means without written permission of: Silicon Image, Inc., */ /* 1060 East Arques Avenue, Sunnyvale, California 94085 */ /***********************************************************************************/ #include "typedefs.h" #include "eedefs.h" #include "video.h" #ifndef __EEPROM_H_20100414_ #define __EEPROM_H_20100414_ HI_U8 CheckVersionID(void); void WriteDefaultConfigToEEPROM( void); HI_U8 ReadByteEEPROM(HI_U8); void WriteByteEEPROM(HI_U8, HI_U8); void BlockWriteEEPROM(HI_U8, HI_U16, HI_U8 *); HI_U8 BlockReadEEPROM(HI_U8, HI_U16, HI_U8 *); void WriteWordEEPROM(HI_U8 RegAddr, HI_U16 data); HI_U16 ReadWordEEPROM(HI_U8 RegAddr); #define ReadEECVMPol(OFFSET) ReadByteEEPROM( EE_CUSTVMODE + OFFSET ) #define ReadFullEDIDParserType() ReadByteEEPROM(EE_EDID_PARSER_ADDR) #define ReadEEHStartPos(OFFSET) ReadWordEEPROM( EE_CUSTVMODE + OFFSET + HSTART_OFFSET ) #define ReadEEVStartPos(OFFSET) ReadWordEEPROM( EE_CUSTVMODE + OFFSET + VSTART_OFFSET ) #define ReadEEHRes(OFFSET) ReadWordEEPROM( EE_CUSTVMODE + OFFSET + HRES_OFFSET ) #define ReadEEVRes(OFFSET) ReadWordEEPROM( EE_CUSTVMODE + OFFSET + VRES_OFFSET ) #define ReadEEPixClock(OFFSET) ReadWordEEPROM( EE_CUSTVMODE + OFFSET + FPIX_OFFSET) #endif
47.882353
88
0.667076
a5b82bebae57885d54bda200944aad8595b8805b
1,861
c
C
hcsr04.c
chenyez/Quickbot
9543dd54dad69637624565d56e3fd191a4fd2d4e
[ "MIT" ]
null
null
null
hcsr04.c
chenyez/Quickbot
9543dd54dad69637624565d56e3fd191a4fd2d4e
[ "MIT" ]
null
null
null
hcsr04.c
chenyez/Quickbot
9543dd54dad69637624565d56e3fd191a4fd2d4e
[ "MIT" ]
null
null
null
#include <stdio.h> #include <unistd.h> #include <prussdrv.h> #include <pruss_intc_mapping.h> int main(void) { /* Initialize the PRU */ printf(">> Initializing PRU\n"); tpruss_intc_initdata pruss_intc_initdata = PRUSS_INTC_INITDATA; prussdrv_init(); /* Open PRU Interrupt */ if (prussdrv_open (PRU_EVTOUT_0)) { // Handle failure fprintf(stderr, ">> PRU open failed\n"); return 1; } /* Get the interrupt initialized */ prussdrv_pruintc_init(&pruss_intc_initdata); /* Get pointers to PRU local memory */ void *pruDataMem; //PRUSS0_PRU0_DATARAM, prussdrv_map_prumem(0, &pruDataMem); unsigned int *pruData = (unsigned int *) pruDataMem; printf("pruData=%s\n:",pruDataMem); /* Execute code on PRU */ printf(">> Executing HCSR-04 code\n"); prussdrv_exec_program(0, "hcsr04.bin"); /* Get measurements */ int i = 0; while (i++ < 20) { // Wait for the PRU interrupt prussdrv_pru_wait_event (PRU_EVTOUT_0); prussdrv_pru_clear_event(PRU_EVTOUT_0, PRU0_ARM_INTERRUPT); // prussdrv_pru_wait_event (PRU_EVTOUT_1); // prussdrv_pru_clear_event(PRU_EVTOUT_1, PRU0_ARM_INTERRUPT); // printf("%3d: Distance = %.2f cm, Distance = %.2f cm\n", i, (float) pruData[0] / 58.44, (float)pruData[1]/58.44); // Print the distance received from the sonar // At 20 degrees in dry air the speed of sound is 342.2 cm/sec // so it takes 29.12 us to make 1 cm, i.e. 58.44 us for a roundtrip of 1 cm printf("%3d: Orange Distance = %.2f cm, Yellow Distance = %.2f cm, Red Distance = %.2f cm, Blue Distance = %.2f cm, Green Distance = %.2f cm\n", i, (float) pruData[0] / 58.44, (float)pruData[1]/58.44, (float)pruData[2]/58.44, (float)pruData[3]/58.44, (float) pruData[4] / 58.44); sleep(0.5); } /* Disable PRU and close memory mapping*/ prussdrv_pru_disable(0); prussdrv_exit(); printf(">> PRU Disabled.\r\n"); return (0); }
29.078125
281
0.685653
9d13ac51826077e11f81d6ea244ff6a86a216ce8
1,535
c
C
MdePkg/Library/BaseLib/Ia32/Monitor.c
CEOALT1/RefindPlusUDK
116b957ad735f96fbb6d80a0ba582046960ba164
[ "BSD-2-Clause" ]
2,757
2018-04-28T21:41:36.000Z
2022-03-29T06:33:36.000Z
MdePkg/Library/BaseLib/Ia32/Monitor.c
CEOALT1/RefindPlusUDK
116b957ad735f96fbb6d80a0ba582046960ba164
[ "BSD-2-Clause" ]
20
2019-07-23T15:29:32.000Z
2022-01-21T12:53:04.000Z
MdePkg/Library/BaseLib/Ia32/Monitor.c
CEOALT1/RefindPlusUDK
116b957ad735f96fbb6d80a0ba582046960ba164
[ "BSD-2-Clause" ]
449
2018-05-09T05:54:05.000Z
2022-03-30T14:54:18.000Z
/** @file AsmMonitor function Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ /** Sets up a monitor buffer that is used by AsmMwait(). Executes a MONITOR instruction with the register state specified by Eax, Ecx and Edx. Returns Eax. This function is only available on IA-32 and x64. @param RegisterEax The value to load into EAX or RAX before executing the MONITOR instruction. @param RegisterEcx The value to load into ECX or RCX before executing the MONITOR instruction. @param RegisterEdx The value to load into EDX or RDX before executing the MONITOR instruction. @return RegisterEax **/ UINTN EFIAPI AsmMonitor ( IN UINTN RegisterEax, IN UINTN RegisterEcx, IN UINTN RegisterEdx ) { _asm { mov eax, RegisterEax mov ecx, RegisterEcx mov edx, RegisterEdx _emit 0x0f // monitor _emit 0x01 _emit 0xc8 } }
31.326531
85
0.637785
a0156932a21bba47e61c5f8d254357acfbff2843
7,214
c
C
components/ds1302/ds1302.c
iotechbugs/esp-idf-lib
a7e9b8a511c3466f3fe6753d9e6bff978106c2bf
[ "ISC", "BSD-2-Clause", "MIT" ]
1
2021-01-27T05:21:54.000Z
2021-01-27T05:21:54.000Z
components/ds1302/ds1302.c
iotechbugs/esp-idf-lib
a7e9b8a511c3466f3fe6753d9e6bff978106c2bf
[ "ISC", "BSD-2-Clause", "MIT" ]
null
null
null
components/ds1302/ds1302.c
iotechbugs/esp-idf-lib
a7e9b8a511c3466f3fe6753d9e6bff978106c2bf
[ "ISC", "BSD-2-Clause", "MIT" ]
null
null
null
/** * @file ds1302.h * * ESP-IDF driver for DS1302 RTC * * Ported from esp-open-rtos * * Copyright (C) 2016, 2019 Ruslan V. Uss <unclerus@gmail.com>\n * Copyright (C) 2016 Pavel Merzlyakov <merzlyakovpavel@gmail.com> * * BSD Licensed as described in the file LICENSE */ #include <freertos/FreeRTOS.h> #include <string.h> #include <esp_idf_lib_helpers.h> #include "ds1302.h" #if HELPER_TARGET_VERSION == HELPER_TARGET_VERSION_ESP32_V4 #include <esp32/rom/ets_sys.h> #else #include <rom/ets_sys.h> #endif #define CH_REG 0x80 #define WP_REG 0x8e #define CH_BIT (1 << 7) #define WP_BIT (1 << 7) #define HOUR12_BIT (1 << 7) #define PM_BIT (1 << 5) #define CH_MASK ((uint8_t)(~CH_BIT)) #define WP_MASK ((uint8_t)(~WP_BIT)) #define CLOCK_BURST 0xbe #define RAM_BURST 0xfe #define SECONDS_MASK 0x7f #define HOUR12_MASK 0x1f #define HOUR24_MASK 0x3f #define GPIO_BIT(x) (1ULL << (x)) #define CHECK(x) do { esp_err_t __; if ((__ = x) != ESP_OK) return __; } while (0) #define CHECK_ARG(VAL) do { if (!(VAL)) return ESP_ERR_INVALID_ARG; } while (0) #if HELPER_TARGET_IS_ESP32 static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; #define PORT_ENTER_CRITICAL portENTER_CRITICAL(&mux) #define PORT_EXIT_CRITICAL portEXIT_CRITICAL(&mux) #elif HELPER_TARGET_IS_ESP8266 #define PORT_ENTER_CRITICAL portENTER_CRITICAL() #define PORT_EXIT_CRITICAL portEXIT_CRITICAL() #else #error cannot identify the target #endif #define CHECK_MUX(x) do { esp_err_t __; if ((__ = (x)) != ESP_OK) { PORT_EXIT_CRITICAL; return __; } } while (0) static uint8_t bcd2dec(uint8_t val) { return (val >> 4) * 10 + (val & 0x0f); } static uint8_t dec2bcd(uint8_t val) { return ((val / 10) << 4) + (val % 10); } inline static esp_err_t chip_enable(ds1302_t *dev) { CHECK(gpio_set_level(dev->ce_pin, 1)); ets_delay_us(4); return ESP_OK; } inline static esp_err_t chip_disable(ds1302_t *dev) { return gpio_set_level(dev->ce_pin, 0); } inline static esp_err_t prepare(ds1302_t *dev, gpio_mode_t mode) { CHECK(gpio_set_direction(dev->io_pin, mode)); CHECK(gpio_set_level(dev->sclk_pin, 0)); return chip_enable(dev); } inline static esp_err_t toggle_clock(ds1302_t *dev) { CHECK(gpio_set_level(dev->sclk_pin, 1)); ets_delay_us(1); CHECK(gpio_set_level(dev->sclk_pin, 0)); ets_delay_us(1); return ESP_OK; } static esp_err_t write_byte(ds1302_t *dev, uint8_t b) { for (uint8_t i = 0; i < 8; i++) { CHECK(gpio_set_level(dev->io_pin, (b >> i) & 1)); CHECK(toggle_clock(dev)); } return ESP_OK; } static esp_err_t read_byte(ds1302_t *dev, uint8_t *b) { *b = 0; for (uint8_t i = 0; i < 8; i++) { *b |= gpio_get_level(dev->io_pin) << i; CHECK(toggle_clock(dev)); } return ESP_OK; } static esp_err_t read_register(ds1302_t *dev, uint8_t reg, uint8_t *val) { PORT_ENTER_CRITICAL; CHECK_MUX(prepare(dev, GPIO_MODE_OUTPUT)); CHECK_MUX(write_byte(dev, reg | 0x01)); CHECK_MUX(prepare(dev, GPIO_MODE_INPUT)); CHECK_MUX(read_byte(dev, val)); PORT_EXIT_CRITICAL; return chip_disable(dev); } static esp_err_t write_register(ds1302_t *dev, uint8_t reg, uint8_t val) { PORT_ENTER_CRITICAL; CHECK_MUX(prepare(dev, GPIO_MODE_OUTPUT)); CHECK_MUX(write_byte(dev, reg)); CHECK_MUX(write_byte(dev, val)); PORT_EXIT_CRITICAL; return chip_disable(dev); } static esp_err_t burst_read(ds1302_t *dev, uint8_t reg, uint8_t *dst, uint8_t len) { PORT_ENTER_CRITICAL; CHECK_MUX(prepare(dev, GPIO_MODE_OUTPUT)); CHECK_MUX(write_byte(dev, reg | 0x01)); CHECK_MUX(prepare(dev, GPIO_MODE_INPUT)); for (uint8_t i = 0; i < len; i++, dst++) CHECK_MUX(read_byte(dev, dst)); PORT_EXIT_CRITICAL; return chip_disable(dev); } static esp_err_t burst_write(ds1302_t *dev, uint8_t reg, uint8_t *src, uint8_t len) { PORT_ENTER_CRITICAL; CHECK_MUX(prepare(dev, GPIO_MODE_OUTPUT)); CHECK_MUX(write_byte(dev, reg)); for (uint8_t i = 0; i < len; i++, src++) CHECK_MUX(write_byte(dev, *src)); PORT_EXIT_CRITICAL; return chip_disable(dev); } static esp_err_t update_register(ds1302_t *dev, uint8_t reg, uint8_t mask, uint8_t val) { uint8_t r; CHECK(read_register(dev, reg, &r)); return write_register(dev, reg, (r & mask) | val); } /////////////////////////////////////////////////////////////////////////////// esp_err_t ds1302_init(ds1302_t *dev) { CHECK_ARG(dev); gpio_config_t io_conf; memset(&io_conf, 0, sizeof(gpio_config_t)); io_conf.mode = GPIO_MODE_OUTPUT; io_conf.pin_bit_mask = GPIO_BIT(dev->ce_pin) | GPIO_BIT(dev->io_pin) | GPIO_BIT(dev->sclk_pin); CHECK(gpio_config(&io_conf)); bool r; CHECK(ds1302_is_running(dev, &r)); dev->ch = !r; return ESP_OK; } esp_err_t ds1302_start(ds1302_t *dev, bool start) { CHECK_ARG(dev); CHECK(update_register(dev, CH_REG, CH_MASK, start ? 0 : CH_BIT)); dev->ch = !start; return ESP_OK; } esp_err_t ds1302_is_running(ds1302_t *dev, bool *running) { CHECK_ARG(dev && running); uint8_t r; CHECK(read_register(dev, CH_REG, &r)); *running = !(r & CH_BIT); dev->ch = !*running; return ESP_OK; } esp_err_t ds1302_set_write_protect(ds1302_t *dev, bool wp) { CHECK_ARG(dev); return update_register(dev, WP_REG, WP_MASK, wp ? WP_BIT : 0); } esp_err_t ds1302_get_write_protect(ds1302_t *dev, bool *wp) { CHECK_ARG(dev && wp); uint8_t r; CHECK(read_register(dev, WP_REG, &r)); *wp = (r & WP_BIT) != 0; return ESP_OK; } esp_err_t ds1302_get_time(ds1302_t *dev, struct tm *time) { CHECK_ARG(dev && time); uint8_t buf[7]; CHECK(burst_read(dev, CLOCK_BURST, buf, 7)); time->tm_sec = bcd2dec(buf[0] & SECONDS_MASK); time->tm_min = bcd2dec(buf[1]); if (buf[2] & HOUR12_BIT) { // RTC in 12-hour mode time->tm_hour = bcd2dec(buf[2] & HOUR12_MASK) - 1; if (buf[2] & PM_BIT) time->tm_hour += 12; } else time->tm_hour = bcd2dec(buf[2] & HOUR24_MASK); time->tm_mday = bcd2dec(buf[3]); time->tm_mon = bcd2dec(buf[4]) - 1; time->tm_wday = bcd2dec(buf[5]) - 1; time->tm_year = bcd2dec(buf[6]) + 100; return ESP_OK; } esp_err_t ds1302_set_time(ds1302_t *dev, const struct tm *time) { CHECK_ARG(dev && time); uint8_t buf[8] = { dec2bcd(time->tm_sec) | (dev->ch ? CH_BIT : 0), dec2bcd(time->tm_min), dec2bcd(time->tm_hour), dec2bcd(time->tm_mday), dec2bcd(time->tm_mon + 1), dec2bcd(time->tm_wday + 1), dec2bcd(time->tm_year - 100), 0 }; return burst_write(dev, CLOCK_BURST, buf, 8); } esp_err_t ds1302_read_sram(ds1302_t *dev, uint8_t offset, void *buf, uint8_t len) { CHECK_ARG(dev && buf && len); CHECK_ARG(offset + len <= DS1302_RAM_SIZE); return burst_read(dev, RAM_BURST, (uint8_t *)buf, len); } esp_err_t ds1302_write_sram(ds1302_t *dev, uint8_t offset, void *buf, uint8_t len) { CHECK_ARG(dev && buf && len); CHECK_ARG(offset + len <= DS1302_RAM_SIZE); return burst_write(dev, RAM_BURST, (uint8_t *)buf, len); }
24.875862
112
0.654976
162096957c75da946227ae344e6230274bfb87e2
931
h
C
OutPutHeaders/WCRedEnvelopesBaseViewController.h
cocos543/WeChatTimeLineRobot
1e93480e502e36ca9a21a506f481aa1fcb70ac4b
[ "MIT" ]
106
2016-04-09T01:16:14.000Z
2021-06-04T00:20:24.000Z
OutPutHeaders/WCRedEnvelopesBaseViewController.h
cocos543/WeChatTimeLineRobot
1e93480e502e36ca9a21a506f481aa1fcb70ac4b
[ "MIT" ]
2
2017-06-13T09:41:29.000Z
2018-03-26T03:32:07.000Z
OutPutHeaders/WCRedEnvelopesBaseViewController.h
cocos543/WeChatTimeLineRobot
1e93480e502e36ca9a21a506f481aa1fcb70ac4b
[ "MIT" ]
58
2016-04-28T09:52:08.000Z
2021-12-25T06:42:14.000Z
/** * This header is generated by class-dump-z 0.2a. * class-dump-z is Copyright (C) 2009 by KennyTM~, licensed under GPLv3. * * Source: (null) */ #import "WeChat-Structs.h" #import "MMTableViewInfoDelegate.h" #import "UIAlertViewDelegate.h" #import "WCBizBaseViewController.h" #import "WCBaseInfoItemDelegate.h" @class NSString, WCRedEnvelopesControlData; @interface WCRedEnvelopesBaseViewController : WCBizBaseViewController <MMTableViewInfoDelegate, WCBaseInfoItemDelegate, UIAlertViewDelegate> { WCRedEnvelopesControlData* m_data; } @property(readonly, copy) NSString* debugDescription; @property(readonly, copy) NSString* description; @property(readonly, assign) Class superclass; @property(readonly, assign) unsigned hash; -(void).cxx_destruct; -(void)refreshViewWithData:(id)data; -(void)setupWithData:(id)data; -(void)dealloc; -(void)viewDidLayoutSubviews; -(void)viewWillLayoutSubviews; -(void)viewDidLoad; @end
29.09375
142
0.787325
38ec3fbdd39bc5c0d20cfcf23741487fbde91845
3,499
c
C
examples/rdkafka_producer_example.c
zlecky/gamecell
309c4e094ed214f79183429e2d2ae9a1464f9b45
[ "MIT" ]
null
null
null
examples/rdkafka_producer_example.c
zlecky/gamecell
309c4e094ed214f79183429e2d2ae9a1464f9b45
[ "MIT" ]
null
null
null
examples/rdkafka_producer_example.c
zlecky/gamecell
309c4e094ed214f79183429e2d2ae9a1464f9b45
[ "MIT" ]
null
null
null
#include <stdio.h> #include <signal.h> #include <memory.h> #include <librdkafka/rdkafka.h> static volatile sig_atomic_t run = 1; /* * @brief signal terminal of program */ static void stop(int sig) { run = 0; fclose(stdin); } static void dr_msg_cb(rd_kafka_t* rk, const rd_kafka_message_t* msg, void* opque) { if (msg->err) { fprintf(stderr, "%% Message delivery failed: %s\n", rd_kafka_err2str(msg->err)); } else { fprintf(stdout, "%% Message delivered %zd bytes, partition %d", msg->len, msg->partition); } /* The msg is destroyed automatically by librdkafka */ } int main(int argc, char* argv[]) { rd_kafka_t* rk = NULL; rd_kafka_conf_t* conf = NULL; char errstr[512]; bzero(errstr, sizeof(errstr)); char buf[512]; bzero(buf, sizeof(buf)); const char* brokers = NULL; const char* topic = NULL; if (argc < 3) { fprintf(stderr, "%% Usage: %s <brokers> <topic>\n", argv[0]); return 1; } brokers = argv[1]; topic = argv[2]; // Create kafka client configuration. conf = rd_kafka_conf_new(); // Set bootstrap.server brokers. if (rd_kafka_conf_set(conf, "bootstrap.servers", brokers, errstr, sizeof(errstr)) != RD_KAFKA_CONF_OK) { fprintf(stderr, "%% %s\n", errstr); return 1; } // Set the delivery report callback. rd_kafka_conf_set_dr_msg_cb(conf, dr_msg_cb); // Set producer instance. rk = rd_kafka_new(RD_KAFKA_PRODUCER, conf, errstr, sizeof(errstr)); if (!rk) { fprintf(stderr, "%% Failed to create a new producer: %s\n", errstr); return 1; } // Signal handle for clean shutdown signal(SIGINT, stop); fprintf(stderr, "%% Type some text and hit enter to produce message\n" "%% Or just hit enter to only serve delivery reports\n" "%% Press Ctrl-C or Ctrl-D to exit\n"); while (run && fgets(buf, sizeof(buf), stdin)) { rd_kafka_resp_err_t err; size_t len = sizeof(buf); if (buf[len - 1] == '\n') { buf[--len] = '\0'; } if (0 == len) { rd_kafka_poll(rk, 0); continue; } retry: err = rd_kafka_producev(rk, RD_KAFKA_V_TOPIC(topic), RD_KAFKA_V_MSGFLAGS(RD_KAFKA_MSG_F_COPY), RD_KAFKA_V_VALUE(buf, len), RD_KAFKA_V_OPAQUE(NULL), RD_KAFKA_V_END); // Failed to *enqueue* message for producing. if (err) { fprintf(stderr, "%% Failed to produce to topic %s: %s\n", topic, rd_kafka_err2str(err)); if (RD_KAFKA_RESP_ERR__QUEUE_FULL == err) { rd_kafka_poll(rk, 1000); goto retry; } } else { fprintf(stdout, "%% Enqueued msssage (%zd bytes) for topic %s\n", len, topic); } rd_kafka_poll(rk, 0); } // Wait for final messages to be delivered or fail. fprintf(stdout, "%% Flushing final message ...\n"); rd_kafka_flush(rk, 10 * 1000); // If the output queue is still not empty there is an issue with producing messages to the clusters. if (rd_kafka_outq_len(rk) > 0) { fprintf(stderr, "%% %d message(s) were not delivered\n", rd_kafka_outq_len(rk)); } /* Destroy the producer instance */ rd_kafka_destroy(rk); return 0; }
28.217742
108
0.566162
166c79f5f4782d769c96f6b0b20d3522de5f4cb9
3,945
h
C
Blips/Pods/Headers/AWSiOSSDKv2/AWSElasticLoadBalancing.h
andrewapperley/Blips-Client
a724c1e5e179b19b62f454ee15456d9c0b212a8f
[ "MIT" ]
null
null
null
Blips/Pods/Headers/AWSiOSSDKv2/AWSElasticLoadBalancing.h
andrewapperley/Blips-Client
a724c1e5e179b19b62f454ee15456d9c0b212a8f
[ "MIT" ]
null
null
null
Blips/Pods/Headers/AWSiOSSDKv2/AWSElasticLoadBalancing.h
andrewapperley/Blips-Client
a724c1e5e179b19b62f454ee15456d9c0b212a8f
[ "MIT" ]
null
null
null
/* * Copyright 2010-2014 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #import <Foundation/Foundation.h> #import "AWSService.h" #import "AWSElasticLoadBalancingModel.h" @class BFTask; /** * */ @interface AWSElasticLoadBalancing : AWSService @property (nonatomic, strong, readonly) AWSServiceConfiguration *configuration; + (instancetype)defaultElasticLoadBalancing; - (instancetype)initWithConfiguration:(AWSServiceConfiguration *)configuration; - (BFTask *)addTags:(AWSElasticLoadBalancingAddTagsInput *)request; - (BFTask *)applySecurityGroupsToLoadBalancer:(AWSElasticLoadBalancingApplySecurityGroupsToLoadBalancerInput *)request; - (BFTask *)attachLoadBalancerToSubnets:(AWSElasticLoadBalancingAttachLoadBalancerToSubnetsInput *)request; - (BFTask *)configureHealthCheck:(AWSElasticLoadBalancingConfigureHealthCheckInput *)request; - (BFTask *)createAppCookieStickinessPolicy:(AWSElasticLoadBalancingCreateAppCookieStickinessPolicyInput *)request; - (BFTask *)createLBCookieStickinessPolicy:(AWSElasticLoadBalancingCreateLBCookieStickinessPolicyInput *)request; - (BFTask *)createLoadBalancer:(AWSElasticLoadBalancingCreateAccessPointInput *)request; - (BFTask *)createLoadBalancerListeners:(AWSElasticLoadBalancingCreateLoadBalancerListenerInput *)request; - (BFTask *)createLoadBalancerPolicy:(AWSElasticLoadBalancingCreateLoadBalancerPolicyInput *)request; - (BFTask *)deleteLoadBalancer:(AWSElasticLoadBalancingDeleteAccessPointInput *)request; - (BFTask *)deleteLoadBalancerListeners:(AWSElasticLoadBalancingDeleteLoadBalancerListenerInput *)request; - (BFTask *)deleteLoadBalancerPolicy:(AWSElasticLoadBalancingDeleteLoadBalancerPolicyInput *)request; - (BFTask *)deregisterInstancesFromLoadBalancer:(AWSElasticLoadBalancingDeregisterEndPointsInput *)request; - (BFTask *)describeInstanceHealth:(AWSElasticLoadBalancingDescribeEndPointStateInput *)request; - (BFTask *)describeLoadBalancerAttributes:(AWSElasticLoadBalancingDescribeLoadBalancerAttributesInput *)request; - (BFTask *)describeLoadBalancerPolicies:(AWSElasticLoadBalancingDescribeLoadBalancerPoliciesInput *)request; - (BFTask *)describeLoadBalancerPolicyTypes:(AWSElasticLoadBalancingDescribeLoadBalancerPolicyTypesInput *)request; - (BFTask *)describeLoadBalancers:(AWSElasticLoadBalancingDescribeAccessPointsInput *)request; - (BFTask *)describeTags:(AWSElasticLoadBalancingDescribeTagsInput *)request; - (BFTask *)detachLoadBalancerFromSubnets:(AWSElasticLoadBalancingDetachLoadBalancerFromSubnetsInput *)request; - (BFTask *)disableAvailabilityZonesForLoadBalancer:(AWSElasticLoadBalancingRemoveAvailabilityZonesInput *)request; - (BFTask *)enableAvailabilityZonesForLoadBalancer:(AWSElasticLoadBalancingAddAvailabilityZonesInput *)request; - (BFTask *)modifyLoadBalancerAttributes:(AWSElasticLoadBalancingModifyLoadBalancerAttributesInput *)request; - (BFTask *)registerInstancesWithLoadBalancer:(AWSElasticLoadBalancingRegisterEndPointsInput *)request; - (BFTask *)removeTags:(AWSElasticLoadBalancingRemoveTagsInput *)request; - (BFTask *)setLoadBalancerListenerSSLCertificate:(AWSElasticLoadBalancingSetLoadBalancerListenerSSLCertificateInput *)request; - (BFTask *)setLoadBalancerPoliciesForBackendServer:(AWSElasticLoadBalancingSetLoadBalancerPoliciesForBackendServerInput *)request; - (BFTask *)setLoadBalancerPoliciesOfListener:(AWSElasticLoadBalancingSetLoadBalancerPoliciesOfListenerInput *)request; @end
43.833333
131
0.840811
558026dfb8da0f72fd40d241179d5e73af98597c
7,222
c
C
src/CHAPTR09/wcMT_VTP.c
yottaawesome/windows-system-programming-4th
f5baded37ca3b820fe9a39adfd877c02d39693c1
[ "MIT" ]
3
2020-12-23T02:14:44.000Z
2021-11-14T11:57:12.000Z
src/CHAPTR09/wcMT_VTP.c
yottaawesome/windows-system-programming-4th
f5baded37ca3b820fe9a39adfd877c02d39693c1
[ "MIT" ]
null
null
null
src/CHAPTR09/wcMT_VTP.c
yottaawesome/windows-system-programming-4th
f5baded37ca3b820fe9a39adfd877c02d39693c1
[ "MIT" ]
2
2021-06-23T18:39:45.000Z
2021-11-14T11:57:16.000Z
/* Chapter 9. wcMT_VTP.c */ /* */ /* wcMT_VTP file1 file2 ... fileN */ /* WARNING: This code is NOT UNICODE enabled */ /* */ /* Parallel word count - NT6 (Vista) thread pool version */ /* */ /* Indpependent procesing of multiple files using */ /* the boss/worker model */ /* count the total number of characters, words, and lines */ /* in the files specified on the command line, just */ /* as is done by the UNIX wc utility */ /* Each file is processed by a separate worker in the TP. */ /* The main thread (the boss thread) accumulates */ /* the separate results to produce the final results */ /* As with all the other "wc" implementations, this uses 8-bit characters */ #include "Everything.h" #define CACHE_LINE_SIZE 64 __declspec(align(CACHE_LINE_SIZE)) typedef struct { /* Structure for thread argument */ char * filename; volatile unsigned int kchar; volatile unsigned int kword; volatile unsigned int kline; volatile unsigned int wcerror; } WORK_OBJECT_ARG; VOID CALLBACK wcfunc (PTP_CALLBACK_INSTANCE, PVOID, PTP_WORK); int WorkerId = 0; // Unique ID computed by each callback instance int main (int argc, char * argv[]) { DWORD nchar = 0, nword = 0, nline = 0; PTP_WORK *pWorkObjects; WORK_OBJECT_ARG ** pWorkObjArgsArray, *pObjectArg; TP_CALLBACK_ENVIRON cbe; // Callback environment int nThread, iThrd; if (!WindowsVersionOK (6, 0)) ReportError ("This program requires Windows NT 6.0 or greater", 1, TRUE); if (argc < 2) { printf ("Usage: wcMT_vtp filename ... filename\n"); return 1; } /* Create a worker thread for each file on the command line */ nThread = (DWORD)argc - 1; pWorkObjects = malloc (nThread * sizeof(PTP_WORK)); if (pWorkObjects != NULL) pWorkObjArgsArray = malloc (nThread * sizeof(WORK_OBJECT_ARG *)); if (pWorkObjects == NULL || pWorkObjArgsArray == NULL) ReportError ("Cannot allocate working memory for worke item or argument array.", 2, TRUE); InitializeThreadpoolEnvironment (&cbe); /* Create a work object argument for each file on the command line. First put the file names in the thread arguments. */ for (iThrd = 0; iThrd < nThread; iThrd++) { pObjectArg = (pWorkObjArgsArray[iThrd] = _aligned_malloc (sizeof(WORK_OBJECT_ARG), CACHE_LINE_SIZE)); if (NULL == pObjectArg) ReportError ("Cannot allocate memory for a thread argument structure.", 3, TRUE); pObjectArg->filename = argv[iThrd+1]; pObjectArg->kword = pObjectArg->kchar = pObjectArg->kline = 0; pWorkObjects[iThrd] = CreateThreadpoolWork (wcfunc, pObjectArg, &cbe); if (pWorkObjects[iThrd] == NULL) ReportError ("Cannot create consumer thread", 4, TRUE); SubmitThreadpoolWork (pWorkObjects[iThrd]); } /* Worker objects are all submitted. Wait for them */ /* to complete and accumulate the results */ for (iThrd = 0; iThrd < nThread; iThrd++) { /* Wait for the thread pool work item to complete */ WaitForThreadpoolWorkCallbacks (pWorkObjects[iThrd], FALSE); CloseThreadpoolWork(pWorkObjects[iThrd]); } free (pWorkObjects); /* Accumulate the results */ for (iThrd = 0; iThrd < argc - 1; iThrd++) { pObjectArg = pWorkObjArgsArray[iThrd]; nchar += pObjectArg->kchar; nword += pObjectArg->kword; nline += pObjectArg->kline; printf ("%10d %9d %9d %s\n", pObjectArg->kline, pObjectArg->kword, pObjectArg->kchar, pObjectArg->filename); } free (pWorkObjArgsArray); printf ("%10d %9d %9d \n", nline, nword, nchar); return 0; } /* Utility function. This is faster than the CLib version */ int is_a_space(int ch) { if(ch == ' ' || ch == '\t' || ch == '\n' || ch == '\f' || ch == '\r') { return 1; } else { return 0; } } /* Mapping files is often faster than conventional I/O. This structure supports a "handle" for the upcoming mapping utility functions */ typedef struct { // Structure for mapped file void* pInFile; HANDLE hInMap; HANDLE hIn; } MAPPED_FILE_HANDLE; /* Mapping utility functions */ /* Challenge: Upgrade this to exploit 64-bit systems. This version is limited to small files */ void* map_file(LPCSTR filename, unsigned int* pFsLow, int* error, MAPPED_FILE_HANDLE* pmFH) { HANDLE hIn, hInMap; LARGE_INTEGER fileSize; char* pInFile; *error = 0; hIn = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hIn == INVALID_HANDLE_VALUE) { *error = 2; return NULL; } // Create a file mapping object on the input file. Use the file size. hInMap = CreateFileMapping(hIn, NULL, PAGE_READONLY, 0, 0, NULL); if (hInMap == NULL) { CloseHandle(hIn); *error = 3; return NULL; } // Map the input file pInFile = (char*) MapViewOfFile(hInMap, FILE_MAP_READ, 0, 0, 0); if (pInFile == NULL) { CloseHandle(hInMap); CloseHandle(hIn); *error = 4; return NULL; } // Get the input file size. As the mapping succeeded, the file size is < 4 GB. Exercise for Reader: Remove the limitation. if (!GetFileSizeEx(hIn, &fileSize) || fileSize.HighPart != 0) { UnmapViewOfFile(pInFile); CloseHandle(hInMap); CloseHandle(hIn); *error = 5; return NULL; } *pFsLow = fileSize.LowPart; pmFH->pInFile = pInFile; pmFH->hInMap = hInMap; pmFH->hIn = hIn; return pInFile; } void UnMapFile(MAPPED_FILE_HANDLE* pmFH) { UnmapViewOfFile(pmFH->pInFile); CloseHandle(pmFH->hInMap); CloseHandle(pmFH->hIn); } /* Thread worker callback function to process a single file */ VOID CALLBACK wcfunc (PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WORK Work) /* Count the number of characters, works, and lines in */ /* the file targ->filename */ /* NOTE: Simple version; results may differ from wc utility */ { WORK_OBJECT_ARG * threadArgs; MAPPED_FILE_HANDLE fhandle; int iThrd; unsigned int ch, c, nl, nw, nc; int isspace_c; // Current character int isspace_ch = 1; // Previous character. Assume space to count first word int error; unsigned int fsize; char *fin, *fend; iThrd = InterlockedIncrement (&WorkerId) - 1; threadArgs = (WORK_OBJECT_ARG *)Context; threadArgs->wcerror = 1; /* Error for now */ fin = (char*) map_file(threadArgs->filename, &fsize, &error, &fhandle); if (NULL == fin) { return; } fend = fin + fsize; ch = nw = nc = nl = 0; while (fin < fend) { c = *fin++; isspace_c = is_a_space(c); if (!isspace_c && isspace_ch) { nw++; } isspace_ch = isspace_c; if (c == '\n') { nl++; isspace_ch = 1; // Start looking for a new word } } UnMapFile(&fhandle); threadArgs->kchar = fsize; threadArgs->kword = nw; threadArgs->kline = nl; threadArgs->wcerror = 0; return; }
31.814978
127
0.625312
be1e70c6ea1fe87ff8ce76883a8fd594f4f14b01
3,731
h
C
auxil/binpac/src/pac_expr.h
hugolin615/zeek-4.0.0-ele420520-spring2021
258e9b2ee1f2a4bd45c6332a75304793b7d44d40
[ "Apache-2.0" ]
1
2021-03-06T19:51:07.000Z
2021-03-06T19:51:07.000Z
auxil/binpac/src/pac_expr.h
hugolin615/zeek-4.0.0-ele420520-spring2021
258e9b2ee1f2a4bd45c6332a75304793b7d44d40
[ "Apache-2.0" ]
null
null
null
auxil/binpac/src/pac_expr.h
hugolin615/zeek-4.0.0-ele420520-spring2021
258e9b2ee1f2a4bd45c6332a75304793b7d44d40
[ "Apache-2.0" ]
null
null
null
#ifndef pac_expr_h #define pac_expr_h #include "pac_common.h" #include "pac_datadep.h" class CaseExpr; class Expr : public Object, public DataDepElement { public: enum ExprType { # define EXPR_DEF(type, x, y) type, # include "pac_expr.def" # undef EXPR_DEF }; void init(); Expr(ID *id); Expr(Number *num); Expr(ConstString *s); Expr(RegEx *regex); Expr(ExprList *args); // for EXPR_CALLARGS Expr(Expr *index, CaseExprList *cases); Expr(ExprType type, Expr *op1); Expr(ExprType type, Expr *op1, Expr *op2); Expr(ExprType type, Expr *op1, Expr *op2, Expr *op3); virtual ~Expr(); const char *orig() const { return orig_.c_str(); } const ID *id() const { return id_; } const char *str() const { return str_.c_str(); } ExprType expr_type() const { return expr_type_; } void AddCaseExpr(CaseExpr *case_expr); // Returns the data "type" of the expression. Here we only // do a serious job for the EXPR_MEMBER and EXPR_SUBSCRIPT // operators. For arithmetic operations, we fall back // to "int". Type *DataType(Env *env) const; string DataTypeStr(Env *env) const; // Note: EvalExpr() may generate C++ statements in order to evaluate // variables in the expression, so the following is wrong: // // out->print("int x = "); // out->println("%s", expr->EvalExpr(out, env)); // // While putting them together is right: // // out->println("int x = %s", expr->EvalExpr(out, env)); // const char *EvalExpr(Output *out, Env *env); // force evaulation of IDs contained in this expression; // necessary with case expr and conditional let fields (&if) // for correct parsing of fields void ForceIDEval(Output *out_cc, Env *env); // Returns the set_* function of the expression. // The expression must be of form ID or x.ID. string SetFunc(Output *out, Env *env); // Returns true if the expression folds to an integer // constant with env, and puts the constant in *pn. // bool ConstFold(Env *env, int *pn) const; // Whether id is referenced in the expression bool HasReference(const ID *id) const; // Suppose the data for type might be incomplete, what is // the minimal number of bytes from data head required to // compute the expression? For example, how many bytes of frame // header do we need to determine the length of the frame? // // The parameter <env> points to the Env of a type. // // Returns -1 if the number is not a constant. // int MinimalHeaderSize(Env *env); // Whether evaluation of the expression requires the analyzer context bool RequiresAnalyzerContext() const; protected: bool DoTraverse(DataDepVisitor *visitor); private: ExprType expr_type_; int num_operands_; Expr *operand_[3]; ID *id_; // EXPR_ID Number *num_; // EXPR_NUM ConstString *cstr_; // EXPR_CSTR RegEx *regex_; // EXPR_REGEX ExprList *args_; // EXPR_CALLARGS CaseExprList *cases_; // EXPR_CASE string str_; // value string string orig_; // original string for debugging info void GenStrFromFormat(Env *env); void GenEval(Output *out, Env *env); void GenCaseEval(Output *out_cc, Env *env); }; string OrigExprList(ExprList *exprlist); string EvalExprList(ExprList *exprlist, Output *out, Env *env); // An entry of the case expression, consisting of one or more constant // expressions for the case index and a value expression. class CaseExpr : public Object, public DataDepElement { public: CaseExpr(ExprList *index, Expr *value); virtual ~CaseExpr(); ExprList *index() const { return index_; } Expr *value() const { return value_; } bool HasReference(const ID *id) const; bool RequiresAnalyzerContext() const; protected: bool DoTraverse(DataDepVisitor *visitor); private: ExprList *index_; Expr *value_; }; #endif // pac_expr_h
26.65
70
0.709193
cea6ff2b071a50adca48232098c3a6abc85582c4
485
h
C
src/add-ons/accelerants/radeon_hd/atombios/atombios-types.h
Kirishikesan/haiku
835565c55830f2dab01e6e332cc7e2d9c015b51e
[ "MIT" ]
1,338
2015-01-03T20:06:56.000Z
2022-03-26T13:49:54.000Z
src/add-ons/accelerants/radeon_hd/atombios/atombios-types.h
Kirishikesan/haiku
835565c55830f2dab01e6e332cc7e2d9c015b51e
[ "MIT" ]
15
2015-01-17T22:19:32.000Z
2021-12-20T12:35:00.000Z
src/add-ons/accelerants/radeon_hd/atombios/atombios-types.h
Kirishikesan/haiku
835565c55830f2dab01e6e332cc7e2d9c015b51e
[ "MIT" ]
350
2015-01-08T14:15:27.000Z
2022-03-21T18:14:35.000Z
/* * Copyright 2013-2014, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Alexander von Gluck, kallisti5@unixzen.com */ #ifndef _ATOMBIOS_TYPES_H #define _ATOMBIOS_TYPES_H #include <SupportDefs.h> #if defined(__POWERPC__) #define ATOM_BIG_ENDIAN 1 #else #define ATOM_BIG_ENDIAN 0 #endif // Align types to Haiku's types typedef uint16 USHORT; typedef uint32 ULONG; typedef uint8 UCHAR; #endif /* _ATOMBIOS_TYPES_H */
16.724138
56
0.74433
cda816226dc249cd1abb9045228f168d8dfb412a
994
c
C
Cerius/src/Cerius/Structs/Node/DNode.c
Afterblue/Cerius
633152f5e5dcd14e0afb45214d31bb846ee3c0c9
[ "MIT" ]
2
2020-03-26T23:08:38.000Z
2020-03-26T23:08:48.000Z
Cerius/src/Cerius/Structs/Node/DNode.c
talberko1/Cerius
633152f5e5dcd14e0afb45214d31bb846ee3c0c9
[ "MIT" ]
null
null
null
Cerius/src/Cerius/Structs/Node/DNode.c
talberko1/Cerius
633152f5e5dcd14e0afb45214d31bb846ee3c0c9
[ "MIT" ]
null
null
null
#pragma once #include "DNode.h" struct DNode { void* data; DNode* next; DNode* prev; }; DNode* new_dnode(void* data) { DNode* this; this = malloc(sizeof(DNode)); this->data = malloc(sizeof(void*)); memcpy(this->data, data, sizeof(void*)); this->next = NULL; this->prev = NULL; return this; } void* dnode_get_data(DNode* this) { return this ? this->data : NULL; } bool dnode_set_data(DNode* this, void* data) { if (this) { memcpy(this->data, data, sizeof(void*)); return true; } return false; } DNode* dnode_get_next(DNode* this) { return this ? this->next : NULL; } bool dnode_set_next(DNode* this, DNode* next) { if (this) { this->next = next; return true; } return false; } DNode* dnode_get_prev(DNode* this) { return this ? this->prev : NULL; } bool dnode_set_prev(DNode* this, DNode* prev) { if (this) { this->prev = prev; return true; } return false; } int free_dnode(DNode* this) { free(this->data); free(this); return sizeof(void*) + sizeof(DNode); }
19.490196
47
0.65996
e045a2aa6fecdb80a643bd7713295e6bde70001d
990
h
C
sdk/DocuSignESign/Model/DSESEmailSettings.h
docusign/docusign-objc-client
17758518642816b24a440cf8b1bec789ede4286d
[ "MIT" ]
15
2016-01-19T23:20:40.000Z
2021-11-14T16:51:12.000Z
sdk/DocuSignESign/Model/DSESEmailSettings.h
docusign/docusign-objc-client
17758518642816b24a440cf8b1bec789ede4286d
[ "MIT" ]
18
2016-02-26T12:43:05.000Z
2022-03-29T01:41:40.000Z
sdk/DocuSignESign/Model/DSESEmailSettings.h
docusign/docusign-objc-client
17758518642816b24a440cf8b1bec789ede4286d
[ "MIT" ]
15
2016-02-11T22:08:01.000Z
2021-11-14T16:51:05.000Z
#import <Foundation/Foundation.h> #import <DSESObject.h> /** * DocuSign REST API * The DocuSign REST API provides you with a powerful, convenient, and simple Web services API for interacting with DocuSign. * * OpenAPI spec version: v2.1 * Contact: devcenter@docusign.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ #import <DSESBccEmailAddress.h> @protocol DSESBccEmailAddress; @class DSESBccEmailAddress; @protocol DSESEmailSettings @end @interface DSESEmailSettings : DSESObject /* A list of email addresses that receive a copy of all email communications for an envelope. You can use this for archiving purposes. [optional] */ @property(nonatomic) NSArray<DSESBccEmailAddress>* bccEmailAddresses; /* [optional] */ @property(nonatomic) NSString* replyEmailAddressOverride; /* [optional] */ @property(nonatomic) NSString* replyEmailNameOverride; @end
25.384615
145
0.773737
b8e06b0c4d45f498909f8c44b01462de145a47f2
379
h
C
KKCommonComponents/KKWebImage/UIImageView+KKWebImage.h
cmadc/CommonComponents
c45a222abf92dbd3a1e4d10d25f66a72c92957ed
[ "MIT" ]
null
null
null
KKCommonComponents/KKWebImage/UIImageView+KKWebImage.h
cmadc/CommonComponents
c45a222abf92dbd3a1e4d10d25f66a72c92957ed
[ "MIT" ]
null
null
null
KKCommonComponents/KKWebImage/UIImageView+KKWebImage.h
cmadc/CommonComponents
c45a222abf92dbd3a1e4d10d25f66a72c92957ed
[ "MIT" ]
1
2020-05-22T02:33:50.000Z
2020-05-22T02:33:50.000Z
// // UIImageView+KKWebImage.h // kakatrip // // Created by CaiMing on 2016/11/8. // Copyright © 2016年 kakatrip. All rights reserved. // #import <UIKit/UIKit.h> @interface UIImageView (KKWebImage) - (void)kk_setImageWithURLString:(NSString *)urlString; - (void)kk_setImageWithURLString:(NSString *)urlString placeholderImage:(UIImage *)placeholder; @end
19.947368
56
0.707124
b4f9bb46b9015dba77b61506a5fcfbc3369caab4
763
h
C
BLEEPlib/src/utility/Random.h
kaistshadow/blockchain-sim
e0dbd23916b9a7ef24c3db6f43e969a63ad6b1f3
[ "MIT" ]
1
2021-09-17T14:18:11.000Z
2021-09-17T14:18:11.000Z
BLEEPlib/src/utility/Random.h
kaistshadow/blockchain-sim
e0dbd23916b9a7ef24c3db6f43e969a63ad6b1f3
[ "MIT" ]
12
2018-06-01T12:29:51.000Z
2021-12-11T06:58:01.000Z
BLEEPlib/src/utility/Random.h
kaistshadow/blockchain-sim
e0dbd23916b9a7ef24c3db6f43e969a63ad6b1f3
[ "MIT" ]
null
null
null
// "Copyright [2021] <kaistshadow>" #ifndef BLEEPLIB_SRC_UTILITY_RANDOM_H_ #define BLEEPLIB_SRC_UTILITY_RANDOM_H_ #include<iostream> #include<set> #include <list> #include <random> namespace libBLEEP { std::list<int> GenRandomNumSet(int maxNum, int maxCount); #define RAND_DROP_NO 0 #define RAND_DROP_NEGATIVE 1 class random_source { private: std::default_random_engine* default_random_source = NULL; public: random_source(); std::default_random_engine* get_default_random_source() { return default_random_source;} double get_normal_value(double avg, double stddev, int flag); double get_exp_value(double lambda); }; random_source& get_global_random_source(); } // namespace libBLEEP #endif // BLEEPLIB_SRC_UTILITY_RANDOM_H_
25.433333
92
0.773263
358f001d51657befb74e845f4c2e915dddba2a81
6,754
c
C
bootloader/common/boot_sd.c
levkovigor/freertos-template2
7fdac94eb8e83da752d6db6cedb323c4e0ee8203
[ "Apache-2.0" ]
null
null
null
bootloader/common/boot_sd.c
levkovigor/freertos-template2
7fdac94eb8e83da752d6db6cedb323c4e0ee8203
[ "Apache-2.0" ]
null
null
null
bootloader/common/boot_sd.c
levkovigor/freertos-template2
7fdac94eb8e83da752d6db6cedb323c4e0ee8203
[ "Apache-2.0" ]
null
null
null
#include "boot_sd.h" #include <bootloaderConfig.h> #include <fatfs_config.h> #include <bsp_sam9g20/common/fram/CommonFRAM.h> #include <hcc/api_hcc_mem.h> #include <at91/memories/sdmmc/MEDSdcard.h> #include <at91/utility/trace.h> #if USE_TINY_FS == 0 #include <bsp_sam9g20/common/SDCardApi.h> #else #include <tinyfatfs/tff.h> #include <peripherals/pio/pio.h> #define MAX_LUNS 1 Media medias[MAX_LUNS]; #endif /* USE_TINY_FS != 1 */ #include <string.h> /** * Will be implemented in a common file because it is also used by NOR-Flash copy algorithm. * @param slotType * @return */ extern int handle_hamming_code_check(SlotType slotType, size_t image_size); int handle_hamming_code_result(int result); #if USE_TINY_FS == 0 int copy_with_hcc_lib(BootSelect boot_select, size_t* image_size); #else int copy_with_tinyfatfs_lib(BootSelect boot_select); #endif int copy_sdcard_binary_to_sdram(BootSelect boot_select, bool use_hamming) { if(boot_select == BOOT_NOR_FLASH) { return -1; } #if USE_TINY_FS == 0 size_t image_size = 0; int result = copy_with_hcc_lib(boot_select, &image_size); if(result != 0) { /* Copy operation failed, we can not jump */ return result; } if(!use_hamming) { return result; } if(boot_select == BOOT_SD_CARD_0_SLOT_0) { result = handle_hamming_code_check(SDC_0_SL_0, image_size); } else if(boot_select == BOOT_SD_CARD_0_SLOT_1) { result = handle_hamming_code_check(SDC_0_SL_1, image_size); } else if(boot_select == BOOT_SD_CARD_1_SLOT_0) { result = handle_hamming_code_check(SDC_1_SL_0, image_size); } else if(boot_select == BOOT_SD_CARD_1_SLOT_1) { result = handle_hamming_code_check(SDC_1_SL_1, image_size); } return handle_hamming_code_result(result); #else return copy_with_tinyfatfs_lib(boot_select); #endif } #if USE_TINY_FS == 0 int copy_with_hcc_lib(BootSelect boot_select, size_t* image_size) { VolumeId current_volume = SD_CARD_0; if (boot_select == BOOT_SD_CARD_1_SLOT_1 || boot_select == BOOT_SD_CARD_1_SLOT_0) { current_volume = SD_CARD_1; } const char* slot_name = NULL; if(boot_select == BOOT_SD_CARD_0_SLOT_1 || boot_select == BOOT_SD_CARD_0_SLOT_1) { slot_name = SW_SLOT_1_NAME; } else { slot_name = SW_SLOT_0_NAME; } #if BOOTLOADER_VERBOSE_LEVEL >= 1 TRACE_INFO("Setting up HCC filesystem\n\r"); #endif /* BOOTLOADER_VERBOSE_LEVEL >= 1 */ int result = open_filesystem(); if(result != F_NO_ERROR) { /* not good, should not happen. */ hcc_mem_delete(); return -1; } result = select_sd_card(current_volume, true); if(result != F_NO_ERROR) { /* not good, should not happen. */ close_filesystem(true, true, current_volume); return -1; } result = change_directory(SW_REPOSITORY, true); if(result != F_NO_ERROR) { #if BOOTLOADER_VERBOSE_LEVEL >= 1 TRACE_WARNING("Target SW repository \"%s\" does not exist\n\r", SW_REPOSITORY); #endif /* not good, should not happen. */ close_filesystem(true, true, current_volume); return -1; } F_FILE* file = f_open(slot_name, "r"); result = f_getlasterror(); if (result != F_NO_ERROR) { #if BOOTLOADER_VERBOSE_LEVEL >= 1 TRACE_WARNING("f_open of file \"%s\" failed with code %d\n\r", slot_name, result); #endif /* opening file failed! */ close_filesystem(true, true, current_volume); return -1; } ssize_t filelength = f_filelength(slot_name); if(filelength <= 0) { #if BOOTLOADER_VERBOSE_LEVEL >= 1 TRACE_ERROR("Copying image \"%s\" from SD-Card %u: File does not exist \n\r", SW_SLOT_1_NAME, (unsigned int) current_volume); #endif /* File does not exist or has an error */ f_close(file); close_filesystem(true, true, current_volume); return -1; } if(image_size != NULL) { *image_size = filelength; } #if BOOTLOADER_VERBOSE_LEVEL >= 1 TRACE_INFO("Copying image \"%s\" from SD card %u to SDRAM\n\r", slot_name, (unsigned int) current_volume); #endif if(f_read((void*) SDRAM_DESTINATION, 1, filelength, file) != filelength) { /* Not all bytes copied! */ f_close(file); close_filesystem(true, true, current_volume); return -1; } f_close(file); close_filesystem(true, true, current_volume); return 0; } #else // Unfortunately, the tiny FATFS library is not working yet. There are issues reading // files on the iOBC, possibly related to hardware related steps which are normally performed // by the HCC and could not be reverse engineered from the information ISIS has given us. int copy_with_tinyfatfs_lib(BootSelect boot_select) { FATFS fs; FIL fileObject; const int ID_DRV = DRV_MMC; FRESULT res = 0; Pin sd_select_pin[1] = {PIN_SDSEL}; PIO_Configure(sd_select_pin, PIO_LISTSIZE(sd_select_pin)); if (boot_select == BOOT_SD_CARD_1_UPDATE) { PIO_Set(sd_select_pin); } else { PIO_Clear(sd_select_pin); } Pin npWrPinsThatDoMagic[2] = {PIN_NPWR_SD0, PIN_NPWR_SD1}; PIO_Configure(npWrPinsThatDoMagic, PIO_LISTSIZE(npWrPinsThatDoMagic)); PIO_Clear(npWrPinsThatDoMagic); PIO_Clear(npWrPinsThatDoMagic + 1); Pin pinsMci1Off[2] = {PINS_MCI1_OFF}; PIO_Configure(pinsMci1Off, PIO_LISTSIZE(pinsMci1Off)); MEDSdcard_Initialize(&medias[ID_DRV], 0); memset(&fs, 0, sizeof(FATFS)); // Clear file system object res = f_mount(0, &fs); if( res != FR_OK ) { printf("f_mount pb: 0x%X\n\r", res); return 0; } char file_name [strlen(SW_REPOSITORY) + strlen(SW_UPDATE_FILE_NAME) + 2]; snprintf(file_name, sizeof (file_name) + 1, "/%s%s", SW_REPOSITORY, SW_UPDATE_FILE_NAME); #if BOOTLOADER_VERBOSE_LEVEL >= 1 TRACE_INFO("Copying image \"%s\" from SD-Card %u to SDRAM\n\r", file_name, (unsigned int) boot_select); #endif res = f_open(&fileObject, file_name, FA_OPEN_EXISTING|FA_READ); if( res != FR_OK ) { TRACE_ERROR("f_open read pb: 0x%X\n\r", res); return 0; } size_t bytes_read; res = f_read(&fileObject, (void*)(SDRAM_DESTINATION), OBSW_MAX_SIZE, &bytes_read); if(res != FR_OK) { TRACE_ERROR("f_read pb: 0x%X\n\r", res); return 0; } #if BOOTLOADER_VERBOSE_LEVEL >= 1 TRACE_INFO("Copied %lu bytes from to SDRAM successfully.\n\r", (unsigned long) bytes_read); #endif res = f_close(&fileObject); if( res != FR_OK ) { TRACE_ERROR("f_close pb: 0x%X\n\r", res); return 0; } return 0; } #endif /* USE_TINY_FS != 1 */
28.987124
95
0.664643
988f1eab287bb53f3f1c59c729b57425e12e2b39
2,238
h
C
libraries/fc/vendor/cyoencode-1.0.2/src/CyoDecode.h
techsharesteam/techshares
47c58630a578204147057b7504e571e19546444f
[ "MIT" ]
6
2018-08-08T06:10:45.000Z
2019-06-23T13:45:08.000Z
libraries/fc/vendor/cyoencode-1.0.2/src/CyoDecode.h
techsharesteam/techshares
47c58630a578204147057b7504e571e19546444f
[ "MIT" ]
null
null
null
libraries/fc/vendor/cyoencode-1.0.2/src/CyoDecode.h
techsharesteam/techshares
47c58630a578204147057b7504e571e19546444f
[ "MIT" ]
2
2018-08-06T06:50:46.000Z
2019-01-03T09:48:54.000Z
/* * CyoDecode.h - part of the CyoEncode library * * Copyright (c) 2009-2012, Graham Bull. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __CYODECODE_H #define __CYODECODE_H #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif /* Base16 Decoding */ int cyoBase16Validate( const char* src, size_t size ); size_t cyoBase16DecodeGetLength( size_t size ); size_t cyoBase16Decode( void* dest, const char* src, size_t size ); /* Base32 Decoding */ int cyoBase32Validate( const char* src, size_t size ); size_t cyoBase32DecodeGetLength( size_t size ); size_t cyoBase32Decode( void* dest, const char* src, size_t size ); /* Base64 Decoding */ int cyoBase64Validate( const char* src, size_t size ); size_t cyoBase64DecodeGetLength( size_t size ); size_t cyoBase64Decode( void* dest, const char* src, size_t size ); #ifdef __cplusplus } #endif #endif /*__CYODECODE_H*/
37.932203
83
0.737265
545c136ffefb11a87910517dce44c0d22d7d8cab
177
h
C
ubench/off-chip_bandwidth/read/DDR/2ports_512bit/src/krnl_config.h
SFU-HiAccel/uBench
429c029414043608fb11bddc1e7f08ed7f60e3c0
[ "BSD-2-Clause" ]
12
2020-12-30T21:43:05.000Z
2021-12-02T18:30:18.000Z
ubench/off-chip_bandwidth/read/DDR/2ports_512bit/src/krnl_config.h
SFU-HiAccel/uBench
429c029414043608fb11bddc1e7f08ed7f60e3c0
[ "BSD-2-Clause" ]
null
null
null
ubench/off-chip_bandwidth/read/DDR/2ports_512bit/src/krnl_config.h
SFU-HiAccel/uBench
429c029414043608fb11bddc1e7f08ed7f60e3c0
[ "BSD-2-Clause" ]
2
2020-12-28T07:33:06.000Z
2021-07-13T07:59:03.000Z
#include "ap_int.h" #include <inttypes.h> const int DWIDTH = 512; #define INTERFACE_WIDTH ap_uint<DWIDTH> const int WIDTH_FACTOR = DWIDTH/32; const int NUM_ITERATIONS = 10000;
22.125
39
0.768362
c247d06561d1d8cccb12df94c647ea83399178a5
9,588
h
C
Stars45/CombatAction.h
RogerioY/starshatter-open
3a507e08b1d4e5970b27401a7e6517570d529400
[ "BSD-3-Clause" ]
null
null
null
Stars45/CombatAction.h
RogerioY/starshatter-open
3a507e08b1d4e5970b27401a7e6517570d529400
[ "BSD-3-Clause" ]
4
2019-09-05T22:22:57.000Z
2021-03-28T02:09:24.000Z
Stars45/CombatAction.h
RogerioY/starshatter-open
3a507e08b1d4e5970b27401a7e6517570d529400
[ "BSD-3-Clause" ]
null
null
null
/* Starshatter OpenSource Distribution Copyright (c) 1997-2004, Destroyer Studios LLC. All Rights Reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name "Destroyer Studios" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SUBSYSTEM: Stars.exe FILE: CombatAction.h AUTHOR: John DiCamillo OVERVIEW ======== A planned action (mission/story/strategy) in a dynamic campaign. */ #ifndef CombatAction_h #define CombatAction_h #include "Types.h" #include "Geometry.h" #include "Text.h" #include "List.h" // +--------------------------------------------------------------------+ class Combatant; class CombatAction; class CombatActionReq; // +--------------------------------------------------------------------+ class CombatAction { public: static const char* TYPENAME() { return "CombatAction"; } enum TYPE { NO_ACTION, STRATEGIC_DIRECTIVE, ZONE_ASSIGNMENT, SYSTEM_ASSIGNMENT, MISSION_TEMPLATE, COMBAT_EVENT, INTEL_EVENT, CAMPAIGN_SITUATION, CAMPAIGN_ORDERS }; enum STATUS { PENDING, ACTIVE, SKIPPED, FAILED, COMPLETE }; CombatAction(int id, int type, int subtype, int team); ~CombatAction(); int operator == (const CombatAction& a) const { return id == a.id; } bool IsAvailable() const; void FireAction(); void FailAction(); void AddRequirement(int action, int stat, bool not = false); void AddRequirement(Combatant* c1, Combatant* c2, int comp, int score); void AddRequirement(Combatant* c1, int group_type, int group_id, int comp, int score, int intel=0); static int TypeFromName(const char* n); static int StatusFromName(const char* n); // accessors/mutators: int Identity() const { return id; } int Type() const { return type; } int Subtype() const { return subtype; } int OpposingType() const { return opp_type; } int GetIFF() const { return team; } int Status() const { return status; } int Source() const { return source; } Point Location() const { return loc; } const char* System() const { return system; } const char* Region() const { return region; } const char* Filename() const { return text_file; } const char* ImageFile() const { return image_file; } const char* SceneFile() const { return scene_file; } int Count() const { return count; } int ExecTime() const { return time; } int StartBefore() const { return start_before; } int StartAfter() const { return start_after; } int MinRank() const { return min_rank; } int MaxRank() const { return max_rank; } int Delay() const { return delay; } int Probability() const { return probability; } int AssetType() const { return asset_type; } int AssetId() const { return asset_id; } List<Text>& AssetKills() { return asset_kills; } int TargetType() const { return target_type; } int TargetId() const { return target_id; } int TargetIFF() const { return target_iff; } List<Text>& TargetKills() { return target_kills; } const char* GetText() const { return text; } void SetType(int t) { type = (char) t; } void SetSubtype(int s) { subtype = (char) s; } void SetOpposingType(int t){ opp_type = (char) t; } void SetIFF(int t) { team = (char) t; } void SetStatus(int s) { status = (char) s; } void SetSource(int s) { source = s; } void SetLocation(const Point& p) { loc = p; } void SetSystem(Text sys) { system = sys; } void SetRegion(Text rgn) { region = rgn; } void SetFilename(Text f) { text_file = f; } void SetImageFile(Text f) { image_file = f; } void SetSceneFile(Text f) { scene_file = f; } void SetCount(int n) { count = (char) n; } void SetExecTime(int t) { time = t; } void SetStartBefore(int s) { start_before = s; } void SetStartAfter(int s) { start_after = s; } void SetMinRank(int n) { min_rank = (char) n; } void SetMaxRank(int n) { max_rank = (char) n; } void SetDelay(int d) { delay = d; } void SetProbability(int n) { probability = n; } void SetAssetType(int t) { asset_type = t; } void SetAssetId(int n) { asset_id = n; } void SetTargetType(int t) { target_type = t; } void SetTargetId(int n) { target_id = n; } void SetTargetIFF(int n) { target_iff = n; } void SetText(Text t) { text = t; } private: int id; char type; char subtype; char opp_type; char team; char status; char min_rank; char max_rank; int source; Point loc; Text system; Text region; Text text_file; Text image_file; Text scene_file; char count; int start_before; int start_after; int delay; int probability; int rval; int time; Text text; int asset_type; int asset_id; List<Text> asset_kills; int target_type; int target_id; int target_iff; List<Text> target_kills; List<CombatActionReq> requirements; }; // +--------------------------------------------------------------------+ class CombatActionReq { public: static const char* TYPENAME() { return "CombatActionReq"; } enum COMPARISON_OPERATOR { LT, LE, GT, GE, EQ, // absolute score comparison RLT, RLE, RGT, RGE, REQ // delta score comparison }; CombatActionReq(int a, int s, bool n = false) : action(a), stat(s), not(n), c1(0), c2(0), comp(0), score(0), intel(0) { } CombatActionReq(Combatant* a1, Combatant* a2, int comparison, int value) : action(0), stat(0), not(0), c1(a1), c2(a2), group_type(0), group_id(0), comp(comparison), score(value), intel(0) { } CombatActionReq(Combatant* a1, int gtype, int gid, int comparison, int value, int intel_level=0) : action(0), stat(0), not(0), c1(a1), c2(0), group_type(gtype), group_id(gid), comp(comparison), score(value), intel(intel_level) { } static int CompFromName(const char* sym); int action; int stat; bool not; Combatant* c1; Combatant* c2; int comp; int score; int intel; int group_type; int group_id; }; #endif CombatAction_h
41.686957
119
0.506988
32c9bf71cd3885d11abfc422249b94baa97d21fe
776
h
C
src/WordDisplay.h
stevefolta/esp8266-ssd1306-display
456683e4f795dd6e04f84254424eed960bb01d8f
[ "MIT" ]
2
2016-04-04T08:05:58.000Z
2018-04-09T11:46:50.000Z
src/WordDisplay.h
stevefolta/esp8266-ssd1306-display
456683e4f795dd6e04f84254424eed960bb01d8f
[ "MIT" ]
null
null
null
src/WordDisplay.h
stevefolta/esp8266-ssd1306-display
456683e4f795dd6e04f84254424eed960bb01d8f
[ "MIT" ]
null
null
null
#ifndef WordDisplay_h #define WordDisplay_h extern "C" { #include "os_type.h" } class SSD1306Display; class WordParser; class WordDisplay { public: WordDisplay(SSD1306Display* oled_display_in); ~WordDisplay(); void show(const char* word); void show_text(const char* text, int text_length, void (*done_fn)(void*), void* done_arg); void show_text(const char* text, void (*done_fn)(void*), void* done_arg) { show_text(text, -1, done_fn, done_arg); } void set_font_size(int size); protected: SSD1306Display* oled_display; WordParser* words; bool shown_para_break; void (*text_done_fn)(void* arg); void* text_done_arg; int y; void next_word(); static void next_word_fn(void* arg); os_timer_t text_timer; }; #endif // !WordDisplay_h
19.4
92
0.715206
e6d12d9cc0999de7b183aa1af9228dda2dd54ed6
238
h
C
firmware/memory/eeprom.h
GClown25/BIT4
1f65c19522155b5ed9ca42b518135f41b21a0cde
[ "MIT" ]
22
2019-04-11T07:09:15.000Z
2021-02-11T14:53:36.000Z
firmware/memory/eeprom.h
GClown25/BIT4
1f65c19522155b5ed9ca42b518135f41b21a0cde
[ "MIT" ]
null
null
null
firmware/memory/eeprom.h
GClown25/BIT4
1f65c19522155b5ed9ca42b518135f41b21a0cde
[ "MIT" ]
1
2019-04-22T08:14:40.000Z
2019-04-22T08:14:40.000Z
/* * eeprom.h * * Created: 08.02.2019 * Author : GClown25 */ #ifndef EEPROM_H #define EEPROM_H void EEPROM_write(unsigned int uiAddress, unsigned char ucData); unsigned char EEPROM_read(unsigned int uiAddress); #endif //EEPROM_H
15.866667
64
0.731092
92c6c2e21f4cd0f17f6ef92bfd8eb02fce0e6e34
664
h
C
OPALApp/PasswordHandling.h
Salooma/OPALRepo
a5815734726f0ce4f749400d98a7ae8f191240ca
[ "MIT" ]
null
null
null
OPALApp/PasswordHandling.h
Salooma/OPALRepo
a5815734726f0ce4f749400d98a7ae8f191240ca
[ "MIT" ]
1
2019-11-17T08:05:58.000Z
2019-11-17T08:05:58.000Z
OPALApp/PasswordHandling.h
Salooma/OPALRepo
a5815734726f0ce4f749400d98a7ae8f191240ca
[ "MIT" ]
null
null
null
// // PasswordHandling.h // OPALApp // // Created by Alexander Figueroa on 2/13/2014. // Copyright (c) 2014 Alexander Figueroa. All rights reserved. // #import <Foundation/Foundation.h> @class TriageViewController; /** @brief The PasswordHandler protocol defines methods for which an object can receive that indicate the actions of the password input in order to verify. */ @protocol PasswordHandling <NSObject> @required - (BOOL)triageViewController:(TriageViewController *)triageViewController verifyPassword:(NSString *)password; @optional // This serves, mostly, as an "update stuff after dismissing" - (void)maxNumberOfFailedAttemptsReached; @end
25.538462
117
0.771084
ddfafb5f9c36ca438330f60a4e1f06f6b3ce438a
581,433
c
C
tools/macroecotools/macroecotools.c
klocey/SADModels
330bf1591c66bcb097bd2ca91c497be0394b734d
[ "MIT" ]
1
2021-03-17T10:32:12.000Z
2021-03-17T10:32:12.000Z
tools/macroecotools/macroecotools.c
klocey/SADModels
330bf1591c66bcb097bd2ca91c497be0394b734d
[ "MIT" ]
null
null
null
tools/macroecotools/macroecotools.c
klocey/SADModels
330bf1591c66bcb097bd2ca91c497be0394b734d
[ "MIT" ]
1
2021-03-18T08:47:37.000Z
2021-03-18T08:47:37.000Z
/* Generated by Cython 0.19.2 on Mon Mar 23 16:42:43 2015 */ #define PY_SSIZE_T_CLEAN #ifndef CYTHON_USE_PYLONG_INTERNALS #ifdef PYLONG_BITS_IN_DIGIT #define CYTHON_USE_PYLONG_INTERNALS 0 #else #include "pyconfig.h" #ifdef PYLONG_BITS_IN_DIGIT #define CYTHON_USE_PYLONG_INTERNALS 1 #else #define CYTHON_USE_PYLONG_INTERNALS 0 #endif #endif #endif #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 < 0x02040000 #error Cython requires Python 2.4+. #else #include <stddef.h> /* For offsetof */ #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 #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_CPYTHON 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX #define PY_SSIZE_T_MIN INT_MIN #define PY_FORMAT_SIZE_T "" #define CYTHON_FORMAT_SSIZE_T "" #define PyInt_FromSsize_t(z) PyInt_FromLong(z) #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ (PyErr_Format(PyExc_TypeError, \ "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ (PyObject*)0)) #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \ !PyComplex_Check(o)) #define PyIndex_Check __Pyx_PyIndex_Check #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) #define __PYX_BUILD_PY_SSIZE_T "i" #else #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #define __Pyx_PyIndex_Check PyIndex_Check #endif #if PY_VERSION_HEX < 0x02060000 #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) #define PyVarObject_HEAD_INIT(type, size) \ PyObject_HEAD_INIT(type) size, #define PyType_Modified(t) typedef struct { void *buf; PyObject *obj; Py_ssize_t len; Py_ssize_t itemsize; int readonly; int ndim; char *format; Py_ssize_t *shape; Py_ssize_t *strides; Py_ssize_t *suboffsets; void *internal; } Py_buffer; #define PyBUF_SIMPLE 0 #define PyBUF_WRITABLE 0x0001 #define PyBUF_FORMAT 0x0004 #define PyBUF_ND 0x0008 #define PyBUF_STRIDES (0x0010 | PyBUF_ND) #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); typedef void (*releasebufferproc)(PyObject *, Py_buffer *); #endif #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, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #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 #if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") #endif #if PY_MAJOR_VERSION >= 3 #define Py_TPFLAGS_CHECKTYPES 0 #define Py_TPFLAGS_HAVE_INDEX 0 #endif #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #if PY_VERSION_HEX < 0x02060000 #define Py_TPFLAGS_HAVE_VERSION_TAG 0 #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_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #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_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #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 #endif #if PY_VERSION_HEX < 0x02060000 #define PyBytesObject PyStringObject #define PyBytes_Type PyString_Type #define PyBytes_Check PyString_Check #define PyBytes_CheckExact PyString_CheckExact #define PyBytes_FromString PyString_FromString #define PyBytes_FromStringAndSize PyString_FromStringAndSize #define PyBytes_FromFormat PyString_FromFormat #define PyBytes_DecodeEscape PyString_DecodeEscape #define PyBytes_AsString PyString_AsString #define PyBytes_AsStringAndSize PyString_AsStringAndSize #define PyBytes_Size PyString_Size #define PyBytes_AS_STRING PyString_AS_STRING #define PyBytes_GET_SIZE PyString_GET_SIZE #define PyBytes_Repr PyString_Repr #define PyBytes_Concat PyString_Concat #define PyBytes_ConcatAndDel PyString_ConcatAndDel #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_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type) #endif #if PY_VERSION_HEX < 0x02060000 #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #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 #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_VERSION_HEX < 0x03020000 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) || (PY_VERSION_HEX >= 0x03010300) #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) #else #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) #endif #if PY_MAJOR_VERSION >= 3 #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #endif #if PY_VERSION_HEX < 0x02050000 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) #else #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) #endif #if PY_VERSION_HEX < 0x02050000 #define __Pyx_NAMESTR(n) ((char *)(n)) #define __Pyx_DOCSTR(n) ((char *)(n)) #else #define __Pyx_NAMESTR(n) (n) #define __Pyx_DOCSTR(n) (n) #endif #ifndef CYTHON_INLINE #if 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 #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 #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is a quiet NaN. */ float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if PY_MAJOR_VERSION >= 3 #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_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #endif #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include <math.h> #define __PYX_HAVE__macroecotools #define __PYX_HAVE_API__macroecotools #ifdef _OPENMP #include <omp.h> #endif /* _OPENMP */ #ifdef PYREX_WITHOUT_ASSERTIONS #define CYTHON_WITHOUT_ASSERTIONS #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 typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(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_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) #define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) #define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return u_end - u - 1; } #else #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen #endif #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_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); #if CYTHON_COMPILING_IN_CPYTHON #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 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params() { PyObject* sys = NULL; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; sys = PyImport_ImportModule("sys"); if (sys == NULL) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); if (default_encoding == NULL) goto bad; if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { const char* default_encoding_c = PyBytes_AS_STRING(default_encoding); 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 == NULL) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (ascii_chars_b == NULL || strncmp(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 '%s' is not a superset of ascii.", default_encoding_c); goto bad; } } Py_XDECREF(sys); Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return 0; bad: Py_XDECREF(sys); 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() { PyObject* sys = NULL; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (sys == NULL) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); if (default_encoding == NULL) goto bad; default_encoding_c = PyBytes_AS_STRING(default_encoding); __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(sys); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(sys); Py_XDECREF(default_encoding); return -1; } #endif #endif #ifdef __GNUC__ /* Test for GCC > 2.95 */ #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* __GNUC__ > 2 ... */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ > 2 ... */ #else /* __GNUC__ */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; 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[] = { "macroecotools.pyx", }; /*--- Type declarations ---*/ #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); /*proto*/ #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 /* CYTHON_REFNANNY */ #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) #if CYTHON_COMPILING_IN_CPYTHON 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); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*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); /*proto*/ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ const char* function_name); /*proto*/ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/ #if CYTHON_COMPILING_IN_CPYTHON 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); Py_SIZE(list) = len+1; return 0; } return PyList_Append(list, x); } #else #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_name, PyObject* args) { PyObject *method, *result = NULL; if (unlikely(!args)) return NULL; method = __Pyx_PyObject_GetAttrStr(obj, method_name); if (unlikely(!method)) goto bad; result = PyObject_Call(method, args, NULL); Py_DECREF(method); bad: Py_DECREF(args); return result; } #define __Pyx_PyObject_CallMethod3(obj, name, arg1, arg2, arg3) \ __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(3, arg1, arg2, arg3)) #define __Pyx_PyObject_CallMethod2(obj, name, arg1, arg2) \ __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(2, arg1, arg2)) #define __Pyx_PyObject_CallMethod1(obj, name, arg1) \ __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(1, arg1)) #define __Pyx_PyObject_CallMethod0(obj, name) \ __Pyx_PyObject_CallMethodTuple(obj, name, (Py_INCREF(__pyx_empty_tuple), __pyx_empty_tuple)) static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x); /*proto*/ #if CYTHON_COMPILING_IN_CPYTHON 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); Py_SIZE(list) = len+1; return 0; } return PyList_Append(list, x); } #else #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) #endif static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ #ifndef __PYX_FORCE_INIT_THREADS #define __PYX_FORCE_INIT_THREADS 0 #endif #define __Pyx_GetItemInt(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ (((size) <= sizeof(Py_ssize_t)) ? \ __Pyx_GetItemInt_Fast(o, i, is_list, wraparound, boundscheck) : \ __Pyx_GetItemInt_Generic(o, to_py_func(i))) #define __Pyx_GetItemInt_List(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ (((size) <= sizeof(Py_ssize_t)) ? \ __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck) : \ __Pyx_GetItemInt_Generic(o, to_py_func(i))) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ (((size) <= sizeof(Py_ssize_t)) ? \ __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck) : \ __Pyx_GetItemInt_Generic(o, to_py_func(i))) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static CYTHON_INLINE 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); 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); static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); #define __Pyx_CyFunction_USED 1 #include <structmember.h> #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; int flags; PyObject *func_dict; PyObject *func_weakreflist; PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_code; PyObject *func_closure; PyObject *func_classobj; /* No-args super() class cell */ void *defaults; int defaults_pyobjects; PyObject *defaults_tuple; /* Const defaults tuple */ PyObject *defaults_kwdict; /* Const kwonly defaults dict */ PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; /* function annotations dict */ } __pyx_CyFunctionObject; static PyTypeObject *__pyx_CyFunctionType = 0; #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, code) \ __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, code) static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *self, PyObject *module, 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); #if PY_VERSION_HEX < 0x02050000 #ifndef PyAnySet_CheckExact #define PyAnySet_CheckExact(ob) \ ((ob)->ob_type == &PySet_Type || \ (ob)->ob_type == &PyFrozenSet_Type) #define PySet_New(iterable) \ PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL) #define Pyx_PyFrozenSet_New(iterable) \ PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL) #define PySet_Size(anyset) \ PyObject_Size((anyset)) #define PySet_Contains(anyset, key) \ PySequence_Contains((anyset), (key)) #define PySet_Pop(set) \ PyObject_CallMethod(set, (char *)"pop", NULL) static CYTHON_INLINE int PySet_Clear(PyObject *set) { PyObject *ret = PyObject_CallMethod(set, (char *)"clear", NULL); if (!ret) return -1; Py_DECREF(ret); return 0; } static CYTHON_INLINE int PySet_Discard(PyObject *set, PyObject *key) { PyObject *ret = PyObject_CallMethod(set, (char *)"discard", (char *)"O", key); if (!ret) return -1; Py_DECREF(ret); return 0; } static CYTHON_INLINE int PySet_Add(PyObject *set, PyObject *key) { PyObject *ret = PyObject_CallMethod(set, (char *)"add", (char *)"O", key); if (!ret) return -1; Py_DECREF(ret); return 0; } #endif /* PyAnySet_CheckExact (<= Py2.4) */ #endif /* < Py2.5 */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/ #if CYTHON_COMPILING_IN_CPYTHON #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) { 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); } #else #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) #endif static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/ static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); static int __Pyx_check_binary_version(void); typedef struct { int code_line; PyCodeObject* code_object; } __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); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /*proto*/ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ /* Module declarations from 'macroecotools' */ #define __Pyx_MODULE_NAME "macroecotools" int __pyx_module_is_main_macroecotools = 0; /* Implementation of 'macroecotools' */ static PyObject *__pyx_builtin_min; static PyObject *__pyx_builtin_sum; static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_max; static PyObject *__pyx_builtin_map; static PyObject *__pyx_builtin_sorted; static PyObject *__pyx_pf_13macroecotools_AIC(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_k, PyObject *__pyx_v_L); /* proto */ static PyObject *__pyx_pf_13macroecotools_2AICc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_k, PyObject *__pyx_v_L, PyObject *__pyx_v_n); /* proto */ static PyObject *__pyx_pf_13macroecotools_4aic_weight(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_AICc_list, PyObject *__pyx_v_n, PyObject *__pyx_v_cutoff); /* proto */ static PyObject *__pyx_pf_13macroecotools_6get_pred_iterative(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cdf_obs, PyObject *__pyx_v_dist, PyObject *__pyx_v_pars); /* proto */ static PyObject *__pyx_pf_13macroecotools_8get_rad_from_cdf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dist, PyObject *__pyx_v_S, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_13macroecotools_10get_emp_cdf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dat); /* proto */ static PyObject *__pyx_pf_13macroecotools_12hist_pmf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_xs, PyObject *__pyx_v_pmf, PyObject *__pyx_v_bins); /* proto */ static PyObject *__pyx_pf_13macroecotools_14plot_rad(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_Ns); /* proto */ static PyObject *__pyx_pf_13macroecotools_16get_rad_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_Ns); /* proto */ static PyObject *__pyx_pf_13macroecotools_18preston_sad(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_abund_vector, PyObject *__pyx_v_b, PyObject *__pyx_v_normalized); /* proto */ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x); /* proto */ static PyObject *__pyx_pf_13macroecotools_20plot_SARs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_list_of_A_and_S); /* proto */ static PyObject *__pyx_pf_13macroecotools_22count_pts_within_radius(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_radius, PyObject *__pyx_v_logscale); /* proto */ static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_point); /* proto */ static PyObject *__pyx_pf_13macroecotools_24plot_color_by_pt_dens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_radius, PyObject *__pyx_v_loglog, PyObject *__pyx_v_plot_obj); /* proto */ static PyObject *__pyx_pf_13macroecotools_26e_var(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_abundance_data); /* proto */ static PyObject *__pyx_pf_13macroecotools_28obs_pred_rsquare(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obs, PyObject *__pyx_v_pred); /* proto */ static PyObject *__pyx_pf_13macroecotools_30obs_pred_mse(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obs, PyObject *__pyx_v_pred); /* proto */ static PyObject *__pyx_pf_13macroecotools_32comp_ed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_spdata1, PyObject *__pyx_v_abdata1, PyObject *__pyx_v_spdata2, PyObject *__pyx_v_abdata2); /* proto */ static PyObject *__pyx_pf_13macroecotools_34calc_comp_eds(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ifile, PyObject *__pyx_v_fout, PyObject *__pyx_v_cutoff); /* proto */ static PyObject *__pyx_pf_13macroecotools_36combined_spID(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_species_identifiers); /* proto */ static PyObject *__pyx_pf_13macroecotools_38richness_in_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_composition_data, PyObject *__pyx_v_group_cols, PyObject *__pyx_v_spid_cols); /* proto */ static PyObject *__pyx_pf_13macroecotools_40abundance_in_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_composition_data, PyObject *__pyx_v_group_cols, PyObject *__pyx_v_abund_col); /* proto */ static char __pyx_k_1[] = "bo-"; static char __pyx_k_5[] = "plot_SARs.<locals>.<lambda>"; static char __pyx_k_8[] = "count_pts_within_radius"; static char __pyx_k_9[] = "plot_color_by_pt_dens.<locals>.<lambda>"; static char __pyx_k_25[] = "Module for conducting standard macroecological plots and analyses"; static char __pyx_k_26[] = "matplotlib.pyplot"; static char __pyx_k_27[] = "*"; static char __pyx_k_30[] = "/Users/lisalocey/tools/macroecotools/macroecotools.pyx"; static char __pyx_k_33[] = "relative_likelihoods"; static char __pyx_k_56[] = "plot_color_by_pt_dens"; static char __pyx_k__L[] = "L"; static char __pyx_k__N[] = "N"; static char __pyx_k__S[] = "S"; static char __pyx_k__a[] = "a"; static char __pyx_k__b[] = "b"; static char __pyx_k__c[] = "c"; static char __pyx_k__i[] = "i"; static char __pyx_k__j[] = "j"; static char __pyx_k__k[] = "k"; static char __pyx_k__n[] = "n"; static char __pyx_k__q[] = "q"; static char __pyx_k__x[] = "x"; static char __pyx_k__y[] = "y"; static char __pyx_k__Ns[] = "Ns"; static char __pyx_k__ab[] = "ab"; static char __pyx_k__ed[] = "ed"; static char __pyx_k__no[] = "no"; static char __pyx_k__np[] = "np"; static char __pyx_k__pi[] = "pi"; static char __pyx_k__v1[] = "v1"; static char __pyx_k__v2[] = "v2"; static char __pyx_k__xs[] = "xs"; static char __pyx_k__AIC[] = "AIC"; static char __pyx_k__dat[] = "dat"; static char __pyx_k__exp[] = "exp"; static char __pyx_k__key[] = "key"; static char __pyx_k__log[] = "log"; static char __pyx_k__map[] = "map"; static char __pyx_k__max[] = "max"; static char __pyx_k__min[] = "min"; static char __pyx_k__obs[] = "obs"; static char __pyx_k__plt[] = "plt"; static char __pyx_k__pmf[] = "pmf"; static char __pyx_k__ppf[] = "ppf"; static char __pyx_k__rad[] = "rad"; static char __pyx_k__sum[] = "sum"; static char __pyx_k__yes[] = "yes"; static char __pyx_k__AICc[] = "AICc"; static char __pyx_k__Area[] = "Area"; static char __pyx_k__Rank[] = "Rank"; static char __pyx_k__args[] = "args"; static char __pyx_k__axes[] = "axes"; static char __pyx_k__bins[] = "bins"; static char __pyx_k__core[] = "core"; static char __pyx_k__dist[] = "dist"; static char __pyx_k__exp2[] = "exp2"; static char __pyx_k__fout[] = "fout"; static char __pyx_k__hist[] = "hist"; static char __pyx_k__hold[] = "hold"; static char __pyx_k__mean[] = "mean"; static char __pyx_k__none[] = "none"; static char __pyx_k__pars[] = "pars"; static char __pyx_k__plot[] = "plot"; static char __pyx_k__pred[] = "pred"; static char __pyx_k__rank[] = "rank"; static char __pyx_k__site[] = "site"; static char __pyx_k__size[] = "size"; static char __pyx_k__sort[] = "sort"; static char __pyx_k__sqrt[] = "sqrt"; static char __pyx_k__xval[] = "xval"; static char __pyx_k__yval[] = "yval"; static char __pyx_k___spid[] = "_spid"; static char __pyx_k__array[] = "array"; static char __pyx_k__color[] = "color"; static char __pyx_k__e_var[] = "e_var"; static char __pyx_k__empty[] = "empty"; static char __pyx_k__ifile[] = "ifile"; static char __pyx_k__log10[] = "log10"; static char __pyx_k__numpy[] = "numpy"; static char __pyx_k__point[] = "point"; static char __pyx_k__range[] = "range"; static char __pyx_k__round[] = "round"; static char __pyx_k__zeros[] = "zeros"; static char __pyx_k__Series[] = "Series"; static char __pyx_k__append[] = "append"; static char __pyx_k__arctan[] = "arctan"; static char __pyx_k__cutoff[] = "cutoff"; static char __pyx_k__loglog[] = "loglog"; static char __pyx_k__pandas[] = "pandas"; static char __pyx_k__radius[] = "radius"; static char __pyx_k__relab1[] = "relab1"; static char __pyx_k__relab2[] = "relab2"; static char __pyx_k__series[] = "series"; static char __pyx_k__sorted[] = "sorted"; static char __pyx_k__usites[] = "usites"; static char __pyx_k__xlabel[] = "xlabel"; static char __pyx_k__ylabel[] = "ylabel"; static char __pyx_k__abdata1[] = "abdata1"; static char __pyx_k__abdata2[] = "abdata2"; static char __pyx_k__cdf_cum[] = "cdf_cum"; static char __pyx_k__cdf_obs[] = "cdf_obs"; static char __pyx_k__columns[] = "columns"; static char __pyx_k__comp_ed[] = "comp_ed"; static char __pyx_k__emp_cdf[] = "emp_cdf"; static char __pyx_k__groupby[] = "groupby"; static char __pyx_k__hist_ab[] = "hist_ab"; static char __pyx_k__ndarray[] = "ndarray"; static char __pyx_k__nunique[] = "nunique"; static char __pyx_k__results[] = "results"; static char __pyx_k__reverse[] = "reverse"; static char __pyx_k__scatter[] = "scatter"; static char __pyx_k__spdata1[] = "spdata1"; static char __pyx_k__spdata2[] = "spdata2"; static char __pyx_k__species[] = "species"; static char __pyx_k__sublist[] = "sublist"; static char __pyx_k__AICc_min[] = "AICc_min"; static char __pyx_k__Richness[] = "Richness"; static char __pyx_k____main__[] = "__main__"; static char __pyx_k____test__[] = "__test__"; static char __pyx_k__colorsys[] = "colorsys"; static char __pyx_k__hist_pmf[] = "hist_pmf"; static char __pyx_k__logscale[] = "logscale"; static char __pyx_k__plot_obj[] = "plot_obj"; static char __pyx_k__plot_rad[] = "plot_rad"; static char __pyx_k__raw_data[] = "raw_data"; static char __pyx_k__richness[] = "richness"; static char __pyx_k__set_xlim[] = "set_xlim"; static char __pyx_k__set_ylim[] = "set_ylim"; static char __pyx_k__spid_col[] = "spid_col"; static char __pyx_k__AICc_list[] = "AICc_list"; static char __pyx_k__Abundance[] = "Abundance"; static char __pyx_k__DataFrame[] = "DataFrame"; static char __pyx_k__Ns_sorted[] = "Ns_sorted"; static char __pyx_k__abund_col[] = "abund_col"; static char __pyx_k__abundance[] = "abundance"; static char __pyx_k__histogram[] = "histogram"; static char __pyx_k__plot_SARs[] = "plot_SARs"; static char __pyx_k__plot_data[] = "plot_data"; static char __pyx_k__point_cdf[] = "point_cdf"; static char __pyx_k__setdiff12[] = "setdiff12"; static char __pyx_k__setdiff1d[] = "setdiff1d"; static char __pyx_k__setdiff21[] = "setdiff21"; static char __pyx_k__spid_cols[] = "spid_cols"; static char __pyx_k__transpose[] = "transpose"; static char __pyx_k__writerows[] = "writerows"; static char __pyx_k__HSV_tuples[] = "HSV_tuples"; static char __pyx_k__RGB_tuples[] = "RGB_tuples"; static char __pyx_k____import__[] = "__import__"; static char __pyx_k__aic_weight[] = "aic_weight"; static char __pyx_k__count_data[] = "count_data"; static char __pyx_k__delta_AICc[] = "delta_AICc"; static char __pyx_k__edgecolors[] = "edgecolors"; static char __pyx_k__group_cols[] = "group_cols"; static char __pyx_k__hsv_to_rgb[] = "hsv_to_rgb"; static char __pyx_k__identifier[] = "identifier"; static char __pyx_k__input_type[] = "input_type"; static char __pyx_k__normalized[] = "normalized"; static char __pyx_k__set_xscale[] = "set_xscale"; static char __pyx_k__set_yscale[] = "set_yscale"; static char __pyx_k__concatenate[] = "concatenate"; static char __pyx_k__get_emp_cdf[] = "get_emp_cdf"; static char __pyx_k__intersect12[] = "intersect12"; static char __pyx_k__preston_sad[] = "preston_sad"; static char __pyx_k__reset_index[] = "reset_index"; static char __pyx_k__setmember1d[] = "setmember1d"; static char __pyx_k__single_spid[] = "single_spid"; static char __pyx_k__spid_series[] = "spid_series"; static char __pyx_k__AICc_weights[] = "AICc_weights"; static char __pyx_k__abund_vector[] = "abund_vector"; static char __pyx_k__column_stack[] = "column_stack"; static char __pyx_k__get_rad_data[] = "get_rad_data"; static char __pyx_k__hist_ab_norm[] = "hist_ab_norm"; static char __pyx_k__intersection[] = "intersection"; static char __pyx_k__ln_nj_over_S[] = "ln_nj_over_S"; static char __pyx_k__obs_pred_mse[] = "obs_pred_mse"; static char __pyx_k__relab_sorted[] = "relab_sorted"; static char __pyx_k__calc_comp_eds[] = "calc_comp_eds"; static char __pyx_k__combined_spID[] = "combined_spID"; static char __pyx_k__hist_ab_norm1[] = "hist_ab_norm1"; static char __pyx_k__hist_ab_norm2[] = "hist_ab_norm2"; static char __pyx_k__macroecotools[] = "macroecotools"; static char __pyx_k__num_neighbors[] = "num_neighbors"; static char __pyx_k__unique_points[] = "unique_points"; static char __pyx_k__abundance_data[] = "abundance_data"; static char __pyx_k__list_of_A_and_S[] = "list_of_A_and_S"; static char __pyx_k__composition_data[] = "composition_data"; static char __pyx_k__get_rad_from_cdf[] = "get_rad_from_cdf"; static char __pyx_k__lower_edge_index[] = "lower_edge_index"; static char __pyx_k__obs_pred_rsquare[] = "obs_pred_rsquare"; static char __pyx_k__sorted_plot_data[] = "sorted_plot_data"; static char __pyx_k__ln_ni_minus_above[] = "ln_ni_minus_above"; static char __pyx_k__richness_in_group[] = "richness_in_group"; static char __pyx_k__single_identifier[] = "single_identifier"; static char __pyx_k__abundance_in_group[] = "abundance_in_group"; static char __pyx_k__get_pred_iterative[] = "get_pred_iterative"; static char __pyx_k__relative_likelihood[] = "relative_likelihood"; static char __pyx_k__species_identifiers[] = "species_identifiers"; static PyObject *__pyx_kp_s_1; static PyObject *__pyx_n_s_26; static PyObject *__pyx_n_s_27; static PyObject *__pyx_kp_s_30; static PyObject *__pyx_n_s_33; static PyObject *__pyx_n_s_5; static PyObject *__pyx_n_s_56; static PyObject *__pyx_n_s_8; static PyObject *__pyx_n_s_9; static PyObject *__pyx_n_s__AIC; static PyObject *__pyx_n_s__AICc; static PyObject *__pyx_n_s__AICc_list; static PyObject *__pyx_n_s__AICc_min; static PyObject *__pyx_n_s__AICc_weights; static PyObject *__pyx_n_s__Abundance; static PyObject *__pyx_n_s__Area; static PyObject *__pyx_n_s__DataFrame; static PyObject *__pyx_n_s__HSV_tuples; static PyObject *__pyx_n_s__L; static PyObject *__pyx_n_s__N; static PyObject *__pyx_n_s__Ns; static PyObject *__pyx_n_s__Ns_sorted; static PyObject *__pyx_n_s__RGB_tuples; static PyObject *__pyx_n_s__Rank; static PyObject *__pyx_n_s__Richness; static PyObject *__pyx_n_s__S; static PyObject *__pyx_n_s__Series; static PyObject *__pyx_n_s____import__; static PyObject *__pyx_n_s____main__; static PyObject *__pyx_n_s____test__; static PyObject *__pyx_n_s___spid; static PyObject *__pyx_n_s__a; static PyObject *__pyx_n_s__ab; static PyObject *__pyx_n_s__abdata1; static PyObject *__pyx_n_s__abdata2; static PyObject *__pyx_n_s__abund_col; static PyObject *__pyx_n_s__abund_vector; static PyObject *__pyx_n_s__abundance; static PyObject *__pyx_n_s__abundance_data; static PyObject *__pyx_n_s__abundance_in_group; static PyObject *__pyx_n_s__aic_weight; static PyObject *__pyx_n_s__append; static PyObject *__pyx_n_s__arctan; static PyObject *__pyx_n_s__args; static PyObject *__pyx_n_s__array; static PyObject *__pyx_n_s__axes; static PyObject *__pyx_n_s__b; static PyObject *__pyx_n_s__bins; static PyObject *__pyx_n_s__c; static PyObject *__pyx_n_s__calc_comp_eds; static PyObject *__pyx_n_s__cdf_cum; static PyObject *__pyx_n_s__cdf_obs; static PyObject *__pyx_n_s__color; static PyObject *__pyx_n_s__colorsys; static PyObject *__pyx_n_s__column_stack; static PyObject *__pyx_n_s__columns; static PyObject *__pyx_n_s__combined_spID; static PyObject *__pyx_n_s__comp_ed; static PyObject *__pyx_n_s__composition_data; static PyObject *__pyx_n_s__concatenate; static PyObject *__pyx_n_s__core; static PyObject *__pyx_n_s__count_data; static PyObject *__pyx_n_s__cutoff; static PyObject *__pyx_n_s__dat; static PyObject *__pyx_n_s__delta_AICc; static PyObject *__pyx_n_s__dist; static PyObject *__pyx_n_s__e_var; static PyObject *__pyx_n_s__ed; static PyObject *__pyx_n_s__edgecolors; static PyObject *__pyx_n_s__emp_cdf; static PyObject *__pyx_n_s__empty; static PyObject *__pyx_n_s__exp; static PyObject *__pyx_n_s__exp2; static PyObject *__pyx_n_s__fout; static PyObject *__pyx_n_s__get_emp_cdf; static PyObject *__pyx_n_s__get_pred_iterative; static PyObject *__pyx_n_s__get_rad_data; static PyObject *__pyx_n_s__get_rad_from_cdf; static PyObject *__pyx_n_s__group_cols; static PyObject *__pyx_n_s__groupby; static PyObject *__pyx_n_s__hist; static PyObject *__pyx_n_s__hist_ab; static PyObject *__pyx_n_s__hist_ab_norm; static PyObject *__pyx_n_s__hist_ab_norm1; static PyObject *__pyx_n_s__hist_ab_norm2; static PyObject *__pyx_n_s__hist_pmf; static PyObject *__pyx_n_s__histogram; static PyObject *__pyx_n_s__hold; static PyObject *__pyx_n_s__hsv_to_rgb; static PyObject *__pyx_n_s__i; static PyObject *__pyx_n_s__identifier; static PyObject *__pyx_n_s__ifile; static PyObject *__pyx_n_s__input_type; static PyObject *__pyx_n_s__intersect12; static PyObject *__pyx_n_s__intersection; static PyObject *__pyx_n_s__j; static PyObject *__pyx_n_s__k; static PyObject *__pyx_n_s__key; static PyObject *__pyx_n_s__list_of_A_and_S; static PyObject *__pyx_n_s__ln_ni_minus_above; static PyObject *__pyx_n_s__ln_nj_over_S; static PyObject *__pyx_n_s__log; static PyObject *__pyx_n_s__log10; static PyObject *__pyx_n_s__loglog; static PyObject *__pyx_n_s__logscale; static PyObject *__pyx_n_s__lower_edge_index; static PyObject *__pyx_n_s__macroecotools; static PyObject *__pyx_n_s__map; static PyObject *__pyx_n_s__max; static PyObject *__pyx_n_s__mean; static PyObject *__pyx_n_s__min; static PyObject *__pyx_n_s__n; static PyObject *__pyx_n_s__ndarray; static PyObject *__pyx_n_s__no; static PyObject *__pyx_n_s__none; static PyObject *__pyx_n_s__normalized; static PyObject *__pyx_n_s__np; static PyObject *__pyx_n_s__num_neighbors; static PyObject *__pyx_n_s__numpy; static PyObject *__pyx_n_s__nunique; static PyObject *__pyx_n_s__obs; static PyObject *__pyx_n_s__obs_pred_mse; static PyObject *__pyx_n_s__obs_pred_rsquare; static PyObject *__pyx_n_s__pandas; static PyObject *__pyx_n_s__pars; static PyObject *__pyx_n_s__pi; static PyObject *__pyx_n_s__plot; static PyObject *__pyx_n_s__plot_SARs; static PyObject *__pyx_n_s__plot_data; static PyObject *__pyx_n_s__plot_obj; static PyObject *__pyx_n_s__plot_rad; static PyObject *__pyx_n_s__plt; static PyObject *__pyx_n_s__pmf; static PyObject *__pyx_n_s__point; static PyObject *__pyx_n_s__point_cdf; static PyObject *__pyx_n_s__ppf; static PyObject *__pyx_n_s__pred; static PyObject *__pyx_n_s__preston_sad; static PyObject *__pyx_n_s__q; static PyObject *__pyx_n_s__rad; static PyObject *__pyx_n_s__radius; static PyObject *__pyx_n_s__range; static PyObject *__pyx_n_s__rank; static PyObject *__pyx_n_s__raw_data; static PyObject *__pyx_n_s__relab1; static PyObject *__pyx_n_s__relab2; static PyObject *__pyx_n_s__relab_sorted; static PyObject *__pyx_n_s__relative_likelihood; static PyObject *__pyx_n_s__reset_index; static PyObject *__pyx_n_s__results; static PyObject *__pyx_n_s__reverse; static PyObject *__pyx_n_s__richness; static PyObject *__pyx_n_s__richness_in_group; static PyObject *__pyx_n_s__round; static PyObject *__pyx_n_s__scatter; static PyObject *__pyx_n_s__series; static PyObject *__pyx_n_s__set_xlim; static PyObject *__pyx_n_s__set_xscale; static PyObject *__pyx_n_s__set_ylim; static PyObject *__pyx_n_s__set_yscale; static PyObject *__pyx_n_s__setdiff12; static PyObject *__pyx_n_s__setdiff1d; static PyObject *__pyx_n_s__setdiff21; static PyObject *__pyx_n_s__setmember1d; static PyObject *__pyx_n_s__single_identifier; static PyObject *__pyx_n_s__single_spid; static PyObject *__pyx_n_s__site; static PyObject *__pyx_n_s__size; static PyObject *__pyx_n_s__sort; static PyObject *__pyx_n_s__sorted; static PyObject *__pyx_n_s__sorted_plot_data; static PyObject *__pyx_n_s__spdata1; static PyObject *__pyx_n_s__spdata2; static PyObject *__pyx_n_s__species; static PyObject *__pyx_n_s__species_identifiers; static PyObject *__pyx_n_s__spid_col; static PyObject *__pyx_n_s__spid_cols; static PyObject *__pyx_n_s__spid_series; static PyObject *__pyx_n_s__sqrt; static PyObject *__pyx_n_s__sublist; static PyObject *__pyx_n_s__sum; static PyObject *__pyx_n_s__transpose; static PyObject *__pyx_n_s__unique_points; static PyObject *__pyx_n_s__usites; static PyObject *__pyx_n_s__v1; static PyObject *__pyx_n_s__v2; static PyObject *__pyx_n_s__writerows; static PyObject *__pyx_n_s__x; static PyObject *__pyx_n_s__xlabel; static PyObject *__pyx_n_s__xs; static PyObject *__pyx_n_s__xval; static PyObject *__pyx_n_s__y; static PyObject *__pyx_n_s__yes; static PyObject *__pyx_n_s__ylabel; static PyObject *__pyx_n_s__yval; static PyObject *__pyx_n_s__zeros; static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_2; static PyObject *__pyx_int_4; static PyObject *__pyx_int_neg_1; static PyObject *__pyx_int_25; static PyObject *__pyx_k_tuple_2; static PyObject *__pyx_k_tuple_3; static PyObject *__pyx_k_tuple_4; static PyObject *__pyx_k_tuple_6; static PyObject *__pyx_k_tuple_7; static PyObject *__pyx_k_slice_12; static PyObject *__pyx_k_slice_14; static PyObject *__pyx_k_slice_16; static PyObject *__pyx_k_slice_18; static PyObject *__pyx_k_slice_20; static PyObject *__pyx_k_slice_22; static PyObject *__pyx_k_slice_24; static PyObject *__pyx_k_tuple_10; static PyObject *__pyx_k_tuple_11; static PyObject *__pyx_k_tuple_13; static PyObject *__pyx_k_tuple_15; static PyObject *__pyx_k_tuple_17; static PyObject *__pyx_k_tuple_19; static PyObject *__pyx_k_tuple_21; static PyObject *__pyx_k_tuple_23; static PyObject *__pyx_k_tuple_28; static PyObject *__pyx_k_tuple_31; static PyObject *__pyx_k_tuple_34; static PyObject *__pyx_k_tuple_36; static PyObject *__pyx_k_tuple_38; static PyObject *__pyx_k_tuple_40; static PyObject *__pyx_k_tuple_42; static PyObject *__pyx_k_tuple_44; static PyObject *__pyx_k_tuple_46; static PyObject *__pyx_k_tuple_48; static PyObject *__pyx_k_tuple_50; static PyObject *__pyx_k_tuple_52; static PyObject *__pyx_k_tuple_54; static PyObject *__pyx_k_tuple_57; static PyObject *__pyx_k_tuple_59; static PyObject *__pyx_k_tuple_61; static PyObject *__pyx_k_tuple_63; static PyObject *__pyx_k_tuple_65; static PyObject *__pyx_k_tuple_67; static PyObject *__pyx_k_tuple_69; static PyObject *__pyx_k_tuple_71; static PyObject *__pyx_k_codeobj_29; static PyObject *__pyx_k_codeobj_32; static PyObject *__pyx_k_codeobj_35; static PyObject *__pyx_k_codeobj_37; static PyObject *__pyx_k_codeobj_39; static PyObject *__pyx_k_codeobj_41; static PyObject *__pyx_k_codeobj_43; static PyObject *__pyx_k_codeobj_45; static PyObject *__pyx_k_codeobj_47; static PyObject *__pyx_k_codeobj_49; static PyObject *__pyx_k_codeobj_51; static PyObject *__pyx_k_codeobj_53; static PyObject *__pyx_k_codeobj_55; static PyObject *__pyx_k_codeobj_58; static PyObject *__pyx_k_codeobj_60; static PyObject *__pyx_k_codeobj_62; static PyObject *__pyx_k_codeobj_64; static PyObject *__pyx_k_codeobj_66; static PyObject *__pyx_k_codeobj_68; static PyObject *__pyx_k_codeobj_70; static PyObject *__pyx_k_codeobj_72; /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_1AIC(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_AIC[] = "Computes the Akaike Information Criterion.\n\n Keyword arguments:\n L -- log likelihood value of given distribution.\n k -- number of fitted parameters.\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_1AIC = {__Pyx_NAMESTR("AIC"), (PyCFunction)__pyx_pw_13macroecotools_1AIC, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_AIC)}; static PyObject *__pyx_pw_13macroecotools_1AIC(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_k = 0; PyObject *__pyx_v_L = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("AIC (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__k,&__pyx_n_s__L,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); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__L)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("AIC", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "AIC") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __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_k = values[0]; __pyx_v_L = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("AIC", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.AIC", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_AIC(__pyx_self, __pyx_v_k, __pyx_v_L); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":11 * import numpy * * def AIC(k, L): # <<<<<<<<<<<<<< * """Computes the Akaike Information Criterion. * */ static PyObject *__pyx_pf_13macroecotools_AIC(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_k, PyObject *__pyx_v_L) { PyObject *__pyx_v_AIC = NULL; 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("AIC", 0); /* "macroecotools.pyx":19 * * """ * AIC = 2 * k - 2 * L # <<<<<<<<<<<<<< * return AIC * */ __pyx_t_1 = PyNumber_Multiply(__pyx_int_2, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Multiply(__pyx_int_2, __pyx_v_L); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __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_v_AIC = __pyx_t_3; __pyx_t_3 = 0; /* "macroecotools.pyx":20 * """ * AIC = 2 * k - 2 * L * return AIC # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_AIC); __pyx_r = __pyx_v_AIC; goto __pyx_L0; __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("macroecotools.AIC", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_AIC); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_3AICc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_2AICc[] = "Computes the corrected Akaike Information Criterion.\n\n Keyword arguments:\n L -- log likelihood value of given distribution.\n k -- number of fitted parameters.\n n -- number of observations.\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_3AICc = {__Pyx_NAMESTR("AICc"), (PyCFunction)__pyx_pw_13macroecotools_3AICc, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_2AICc)}; static PyObject *__pyx_pw_13macroecotools_3AICc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_k = 0; PyObject *__pyx_v_L = 0; PyObject *__pyx_v_n = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("AICc (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__k,&__pyx_n_s__L,&__pyx_n_s__n,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); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__L)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("AICc", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("AICc", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "AICc") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __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_k = values[0]; __pyx_v_L = values[1]; __pyx_v_n = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("AICc", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.AICc", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_2AICc(__pyx_self, __pyx_v_k, __pyx_v_L, __pyx_v_n); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":23 * * * def AICc(k, L, n): # <<<<<<<<<<<<<< * """Computes the corrected Akaike Information Criterion. * */ static PyObject *__pyx_pf_13macroecotools_2AICc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_k, PyObject *__pyx_v_L, PyObject *__pyx_v_n) { PyObject *__pyx_v_AICc = 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_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("AICc", 0); /* "macroecotools.pyx":32 * * """ * AICc = 2 * k - 2 * L + 2 * k * (k + 1) / (n - k - 1) # <<<<<<<<<<<<<< * return AICc * */ __pyx_t_1 = PyNumber_Multiply(__pyx_int_2, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Multiply(__pyx_int_2, __pyx_v_L); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __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 = PyNumber_Multiply(__pyx_int_2, __pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_Add(__pyx_v_k, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Subtract(__pyx_v_n, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_AICc = __pyx_t_2; __pyx_t_2 = 0; /* "macroecotools.pyx":33 * """ * AICc = 2 * k - 2 * L + 2 * k * (k + 1) / (n - k - 1) * return AICc # <<<<<<<<<<<<<< * * def aic_weight(AICc_list, n, cutoff = 4): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_AICc); __pyx_r = __pyx_v_AICc; goto __pyx_L0; __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_AddTraceback("macroecotools.AICc", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_AICc); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_5aic_weight(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_4aic_weight[] = "Computes Akaike weight for one model relative to others\n\n Based on information from Burnham and Anderson (2002).\n\n Keyword arguments:\n n -- number of observations.\n cutoff -- minimum number of observations required to generate a weight.\n AICc_list -- list of AICc values for each model\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_5aic_weight = {__Pyx_NAMESTR("aic_weight"), (PyCFunction)__pyx_pw_13macroecotools_5aic_weight, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_4aic_weight)}; static PyObject *__pyx_pw_13macroecotools_5aic_weight(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_AICc_list = 0; PyObject *__pyx_v_n = 0; PyObject *__pyx_v_cutoff = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("aic_weight (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__AICc_list,&__pyx_n_s__n,&__pyx_n_s__cutoff,0}; PyObject* values[3] = {0,0,0}; values[2] = ((PyObject *)__pyx_int_4); 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); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__AICc_list)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("aic_weight", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cutoff); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "aic_weight") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); 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_AICc_list = values[0]; __pyx_v_n = values[1]; __pyx_v_cutoff = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("aic_weight", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.aic_weight", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_4aic_weight(__pyx_self, __pyx_v_AICc_list, __pyx_v_n, __pyx_v_cutoff); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":35 * return AICc * * def aic_weight(AICc_list, n, cutoff = 4): # <<<<<<<<<<<<<< * """Computes Akaike weight for one model relative to others * */ static PyObject *__pyx_pf_13macroecotools_4aic_weight(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_AICc_list, PyObject *__pyx_v_n, PyObject *__pyx_v_cutoff) { PyObject *__pyx_v_AICc_weights = NULL; PyObject *__pyx_v_AICc_min = NULL; PyObject *__pyx_v_relative_likelihoods = NULL; PyObject *__pyx_v_AICc = NULL; PyObject *__pyx_v_delta_AICc = NULL; PyObject *__pyx_v_relative_likelihood = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("aic_weight", 0); /* "macroecotools.pyx":46 * * """ * if n < cutoff: # <<<<<<<<<<<<<< * AICc_weights = None * */ __pyx_t_1 = PyObject_RichCompare(__pyx_v_n, __pyx_v_cutoff, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* "macroecotools.pyx":47 * """ * if n < cutoff: * AICc_weights = None # <<<<<<<<<<<<<< * * else: */ __Pyx_INCREF(Py_None); __pyx_v_AICc_weights = Py_None; goto __pyx_L3; } /*else*/ { /* "macroecotools.pyx":50 * * else: * AICc_min = min(AICc_list) # Minimum AICc value for the entire list # <<<<<<<<<<<<<< * relative_likelihoods = [] * */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_AICc_list); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_AICc_list); __Pyx_GIVEREF(__pyx_v_AICc_list); __pyx_t_3 = PyObject_Call(__pyx_builtin_min, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_AICc_min = __pyx_t_3; __pyx_t_3 = 0; /* "macroecotools.pyx":51 * else: * AICc_min = min(AICc_list) # Minimum AICc value for the entire list * relative_likelihoods = [] # <<<<<<<<<<<<<< * * for AICc in AICc_list: */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_v_relative_likelihoods = ((PyObject *)__pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":53 * relative_likelihoods = [] * * for AICc in AICc_list: # <<<<<<<<<<<<<< * delta_AICc = AICc - AICc_min * relative_likelihood = np.exp(-(delta_AICc)/2) */ if (PyList_CheckExact(__pyx_v_AICc_list) || PyTuple_CheckExact(__pyx_v_AICc_list)) { __pyx_t_3 = __pyx_v_AICc_list; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_AICc_list); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; } for (;;) { if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_AICc, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":54 * * for AICc in AICc_list: * delta_AICc = AICc - AICc_min # <<<<<<<<<<<<<< * relative_likelihood = np.exp(-(delta_AICc)/2) * relative_likelihoods.append(relative_likelihood) */ __pyx_t_1 = PyNumber_Subtract(__pyx_v_AICc, __pyx_v_AICc_min); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_delta_AICc, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":55 * for AICc in AICc_list: * delta_AICc = AICc - AICc_min * relative_likelihood = np.exp(-(delta_AICc)/2) # <<<<<<<<<<<<<< * relative_likelihoods.append(relative_likelihood) * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__exp); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Negative(__pyx_v_delta_AICc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_int_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_XDECREF_SET(__pyx_v_relative_likelihood, __pyx_t_7); __pyx_t_7 = 0; /* "macroecotools.pyx":56 * delta_AICc = AICc - AICc_min * relative_likelihood = np.exp(-(delta_AICc)/2) * relative_likelihoods.append(relative_likelihood) # <<<<<<<<<<<<<< * * relative_likelihoods = np.array(relative_likelihoods) */ __pyx_t_7 = __Pyx_PyObject_Append(__pyx_v_relative_likelihoods, __pyx_v_relative_likelihood); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":58 * relative_likelihoods.append(relative_likelihood) * * relative_likelihoods = np.array(relative_likelihoods) # <<<<<<<<<<<<<< * * AICc_weights = relative_likelihoods / sum(relative_likelihoods) */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__array); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_relative_likelihoods); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_relative_likelihoods); __Pyx_GIVEREF(__pyx_v_relative_likelihoods); __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_relative_likelihoods, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":60 * relative_likelihoods = np.array(relative_likelihoods) * * AICc_weights = relative_likelihoods / sum(relative_likelihoods) # <<<<<<<<<<<<<< * * return(AICc_weights) */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_relative_likelihoods); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_relative_likelihoods); __Pyx_GIVEREF(__pyx_v_relative_likelihoods); __pyx_t_3 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_v_relative_likelihoods, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_AICc_weights = __pyx_t_1; __pyx_t_1 = 0; /* "macroecotools.pyx":62 * AICc_weights = relative_likelihoods / sum(relative_likelihoods) * * return(AICc_weights) # <<<<<<<<<<<<<< * * def get_pred_iterative(cdf_obs, dist, *pars): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_AICc_weights); __pyx_r = __pyx_v_AICc_weights; goto __pyx_L0; } __pyx_L3:; __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_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("macroecotools.aic_weight", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_AICc_weights); __Pyx_XDECREF(__pyx_v_AICc_min); __Pyx_XDECREF(__pyx_v_relative_likelihoods); __Pyx_XDECREF(__pyx_v_AICc); __Pyx_XDECREF(__pyx_v_delta_AICc); __Pyx_XDECREF(__pyx_v_relative_likelihood); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_7get_pred_iterative(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_6get_pred_iterative[] = "Function to get predicted abundances (reverse-sorted) for distributions with no analytical ppf."; static PyMethodDef __pyx_mdef_13macroecotools_7get_pred_iterative = {__Pyx_NAMESTR("get_pred_iterative"), (PyCFunction)__pyx_pw_13macroecotools_7get_pred_iterative, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_6get_pred_iterative)}; static PyObject *__pyx_pw_13macroecotools_7get_pred_iterative(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_cdf_obs = 0; PyObject *__pyx_v_dist = 0; PyObject *__pyx_v_pars = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_pred_iterative (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_pars = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_pars)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_pars); } else { __pyx_v_pars = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cdf_obs,&__pyx_n_s__dist,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) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cdf_obs)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dist)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("get_pred_iterative", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "get_pred_iterative") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __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_cdf_obs = values[0]; __pyx_v_dist = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_pred_iterative", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_pars); __pyx_v_pars = 0; __Pyx_AddTraceback("macroecotools.get_pred_iterative", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_6get_pred_iterative(__pyx_self, __pyx_v_cdf_obs, __pyx_v_dist, __pyx_v_pars); __Pyx_XDECREF(__pyx_v_pars); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":64 * return(AICc_weights) * * def get_pred_iterative(cdf_obs, dist, *pars): # <<<<<<<<<<<<<< * """Function to get predicted abundances (reverse-sorted) for distributions with no analytical ppf.""" * cdf_obs = np.sort(cdf_obs) */ static PyObject *__pyx_pf_13macroecotools_6get_pred_iterative(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cdf_obs, PyObject *__pyx_v_dist, PyObject *__pyx_v_pars) { PyObject *__pyx_v_abundance = NULL; PyObject *__pyx_v_j = NULL; PyObject *__pyx_v_cdf_cum = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_pred_iterative", 0); __Pyx_INCREF(__pyx_v_cdf_obs); /* "macroecotools.pyx":66 * def get_pred_iterative(cdf_obs, dist, *pars): * """Function to get predicted abundances (reverse-sorted) for distributions with no analytical ppf.""" * cdf_obs = np.sort(cdf_obs) # <<<<<<<<<<<<<< * abundance = list(np.empty([len(cdf_obs)])) * j = 0 */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_cdf_obs); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_cdf_obs); __Pyx_GIVEREF(__pyx_v_cdf_obs); __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_cdf_obs, __pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":67 * """Function to get predicted abundances (reverse-sorted) for distributions with no analytical ppf.""" * cdf_obs = np.sort(cdf_obs) * abundance = list(np.empty([len(cdf_obs)])) # <<<<<<<<<<<<<< * j = 0 * cdf_cum = 0 */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = PyObject_Length(__pyx_v_cdf_obs); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_abundance = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":68 * cdf_obs = np.sort(cdf_obs) * abundance = list(np.empty([len(cdf_obs)])) * j = 0 # <<<<<<<<<<<<<< * cdf_cum = 0 * i = 1 */ __Pyx_INCREF(__pyx_int_0); __pyx_v_j = __pyx_int_0; /* "macroecotools.pyx":69 * abundance = list(np.empty([len(cdf_obs)])) * j = 0 * cdf_cum = 0 # <<<<<<<<<<<<<< * i = 1 * while j < len(cdf_obs): */ __Pyx_INCREF(__pyx_int_0); __pyx_v_cdf_cum = __pyx_int_0; /* "macroecotools.pyx":70 * j = 0 * cdf_cum = 0 * i = 1 # <<<<<<<<<<<<<< * while j < len(cdf_obs): * cdf_cum += dist.pmf(i, *pars) */ __Pyx_INCREF(__pyx_int_1); __pyx_v_i = __pyx_int_1; /* "macroecotools.pyx":71 * cdf_cum = 0 * i = 1 * while j < len(cdf_obs): # <<<<<<<<<<<<<< * cdf_cum += dist.pmf(i, *pars) * while cdf_cum >= cdf_obs[j]: */ while (1) { __pyx_t_4 = PyObject_Length(__pyx_v_cdf_obs); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_RichCompare(__pyx_v_j, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_5) break; /* "macroecotools.pyx":72 * i = 1 * while j < len(cdf_obs): * cdf_cum += dist.pmf(i, *pars) # <<<<<<<<<<<<<< * while cdf_cum >= cdf_obs[j]: * abundance[j] = i */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dist, __pyx_n_s__pmf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_i); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); __pyx_t_1 = PySequence_Tuple(((PyObject *)__pyx_v_pars)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_t_6 = PyNumber_Add(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_cdf_cum, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_cdf_cum, __pyx_t_6); __pyx_t_6 = 0; /* "macroecotools.pyx":73 * while j < len(cdf_obs): * cdf_cum += dist.pmf(i, *pars) * while cdf_cum >= cdf_obs[j]: # <<<<<<<<<<<<<< * abundance[j] = i * j += 1 */ while (1) { __pyx_t_6 = PyObject_GetItem(__pyx_v_cdf_obs, __pyx_v_j); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyObject_RichCompare(__pyx_v_cdf_cum, __pyx_t_6, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_5) break; /* "macroecotools.pyx":74 * cdf_cum += dist.pmf(i, *pars) * while cdf_cum >= cdf_obs[j]: * abundance[j] = i # <<<<<<<<<<<<<< * j += 1 * if j == len(cdf_obs): */ if (PyObject_SetItem(((PyObject *)__pyx_v_abundance), __pyx_v_j, __pyx_v_i) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":75 * while cdf_cum >= cdf_obs[j]: * abundance[j] = i * j += 1 # <<<<<<<<<<<<<< * if j == len(cdf_obs): * abundance.reverse() */ __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_j, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_j, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":76 * abundance[j] = i * j += 1 * if j == len(cdf_obs): # <<<<<<<<<<<<<< * abundance.reverse() * return np.array(abundance) */ __pyx_t_4 = PyObject_Length(__pyx_v_cdf_obs); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_RichCompare(__pyx_v_j, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_5) { /* "macroecotools.pyx":77 * j += 1 * if j == len(cdf_obs): * abundance.reverse() # <<<<<<<<<<<<<< * return np.array(abundance) * i += 1 */ __pyx_t_7 = PyList_Reverse(__pyx_v_abundance); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":78 * if j == len(cdf_obs): * abundance.reverse() * return np.array(abundance) # <<<<<<<<<<<<<< * i += 1 * */ __Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_v_abundance)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_abundance)); __Pyx_GIVEREF(((PyObject *)__pyx_v_abundance)); __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; goto __pyx_L7; } __pyx_L7:; } /* "macroecotools.pyx":79 * abundance.reverse() * return np.array(abundance) * i += 1 # <<<<<<<<<<<<<< * * def get_rad_from_cdf(dist, S, *args): */ __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_3); __pyx_t_3 = 0; } __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_6); __Pyx_AddTraceback("macroecotools.get_pred_iterative", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_abundance); __Pyx_XDECREF(__pyx_v_j); __Pyx_XDECREF(__pyx_v_cdf_cum); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_cdf_obs); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_9get_rad_from_cdf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_8get_rad_from_cdf[] = "Return a predicted rank-abundance distribution from a theoretical CDF\n\n Keyword arguments:\n dist -- a distribution class\n S -- the number of species for which the RAD should be predicted. Should\n match the number of species in the community if comparing to empirical data.\n args -- arguments for dist\n\n Finds the predicted rank-abundance distribution that results from a\n theoretical cumulative distribution function, by rounding the value of the\n cdf evaluated at 1 / S * (Rank - 0.5) to the nearest integer\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_9get_rad_from_cdf = {__Pyx_NAMESTR("get_rad_from_cdf"), (PyCFunction)__pyx_pw_13macroecotools_9get_rad_from_cdf, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_8get_rad_from_cdf)}; static PyObject *__pyx_pw_13macroecotools_9get_rad_from_cdf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_dist = 0; PyObject *__pyx_v_S = 0; PyObject *__pyx_v_args = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_rad_from_cdf (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 2) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dist,&__pyx_n_s__S,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) { default: case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dist)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__S)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("get_rad_from_cdf", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "get_rad_from_cdf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __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_dist = values[0]; __pyx_v_S = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_rad_from_cdf", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("macroecotools.get_rad_from_cdf", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_8get_rad_from_cdf(__pyx_self, __pyx_v_dist, __pyx_v_S, __pyx_v_args); __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":81 * i += 1 * * def get_rad_from_cdf(dist, S, *args): # <<<<<<<<<<<<<< * """Return a predicted rank-abundance distribution from a theoretical CDF * */ static PyObject *__pyx_pf_13macroecotools_8get_rad_from_cdf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dist, PyObject *__pyx_v_S, PyObject *__pyx_v_args) { PyObject *__pyx_v_emp_cdf = NULL; PyObject *__pyx_v_rad = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; 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("get_rad_from_cdf", 0); /* "macroecotools.pyx":95 * * """ * emp_cdf = [(S - i + 0.5) / S for i in range(1, S + 1)] # <<<<<<<<<<<<<< * try: rad = int(np.round(dist.ppf(emp_cdf, *args))) * except: rad = get_pred_iterative(emp_cdf, dist, *args) */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Add(__pyx_v_S, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Subtract(__pyx_v_S, __pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyNumber_Add(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_v_S); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_emp_cdf = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":96 * """ * emp_cdf = [(S - i + 0.5) / S for i in range(1, S + 1)] * try: rad = int(np.round(dist.ppf(emp_cdf, *args))) # <<<<<<<<<<<<<< * except: rad = get_pred_iterative(emp_cdf, dist, *args) * return np.array(rad) */ { __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); /*try:*/ { __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__round); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dist, __pyx_n_s__ppf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_v_emp_cdf)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_emp_cdf)); __Pyx_GIVEREF(((PyObject *)__pyx_v_emp_cdf)); __pyx_t_7 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_7)); __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_rad = __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; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L12_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* "macroecotools.pyx":97 * emp_cdf = [(S - i + 0.5) / S for i in range(1, S + 1)] * try: rad = int(np.round(dist.ppf(emp_cdf, *args))) * except: rad = get_pred_iterative(emp_cdf, dist, *args) # <<<<<<<<<<<<<< * return np.array(rad) * */ /*except:*/ { __Pyx_AddTraceback("macroecotools.get_rad_from_cdf", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_pred_iterative); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_v_emp_cdf)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_emp_cdf)); __Pyx_GIVEREF(((PyObject *)__pyx_v_emp_cdf)); __Pyx_INCREF(__pyx_v_dist); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_dist); __Pyx_GIVEREF(__pyx_v_dist); __pyx_t_11 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_11)); __pyx_t_12 = PyNumber_Add(((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_11)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_12)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; __pyx_t_11 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; __Pyx_XDECREF_SET(__pyx_v_rad, __pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L6_exception_handled; } __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L1_error; __pyx_L6_exception_handled:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); __pyx_L12_try_end:; } /* "macroecotools.pyx":98 * try: rad = int(np.round(dist.ppf(emp_cdf, *args))) * except: rad = get_pred_iterative(emp_cdf, dist, *args) * return np.array(rad) # <<<<<<<<<<<<<< * * def get_emp_cdf(dat): */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_rad); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_rad); __Pyx_GIVEREF(__pyx_v_rad); __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0; __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_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("macroecotools.get_rad_from_cdf", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_emp_cdf); __Pyx_XDECREF(__pyx_v_rad); __Pyx_XDECREF(__pyx_v_i); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_11get_emp_cdf(PyObject *__pyx_self, PyObject *__pyx_v_dat); /*proto*/ static char __pyx_doc_13macroecotools_10get_emp_cdf[] = "Compute the empirical cdf given a list or an array"; static PyMethodDef __pyx_mdef_13macroecotools_11get_emp_cdf = {__Pyx_NAMESTR("get_emp_cdf"), (PyCFunction)__pyx_pw_13macroecotools_11get_emp_cdf, METH_O, __Pyx_DOCSTR(__pyx_doc_13macroecotools_10get_emp_cdf)}; static PyObject *__pyx_pw_13macroecotools_11get_emp_cdf(PyObject *__pyx_self, PyObject *__pyx_v_dat) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_emp_cdf (wrapper)", 0); __pyx_r = __pyx_pf_13macroecotools_10get_emp_cdf(__pyx_self, ((PyObject *)__pyx_v_dat)); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":100 * return np.array(rad) * * def get_emp_cdf(dat): # <<<<<<<<<<<<<< * """Compute the empirical cdf given a list or an array""" * dat = np.array(dat) */ static PyObject *__pyx_pf_13macroecotools_10get_emp_cdf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dat) { PyObject *__pyx_v_emp_cdf = NULL; PyObject *__pyx_v_point = NULL; PyObject *__pyx_v_point_cdf = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); Py_ssize_t __pyx_t_6; Py_ssize_t __pyx_t_7; int __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_emp_cdf", 0); __Pyx_INCREF(__pyx_v_dat); /* "macroecotools.pyx":102 * def get_emp_cdf(dat): * """Compute the empirical cdf given a list or an array""" * dat = np.array(dat) # <<<<<<<<<<<<<< * emp_cdf = [] * for point in dat: */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_dat); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_dat); __Pyx_GIVEREF(__pyx_v_dat); __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_dat, __pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":103 * """Compute the empirical cdf given a list or an array""" * dat = np.array(dat) * emp_cdf = [] # <<<<<<<<<<<<<< * for point in dat: * point_cdf = len(dat[dat <= point]) / len(dat) */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_v_emp_cdf = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":104 * dat = np.array(dat) * emp_cdf = [] * for point in dat: # <<<<<<<<<<<<<< * point_cdf = len(dat[dat <= point]) / len(dat) * emp_cdf.append(point_cdf) */ if (PyList_CheckExact(__pyx_v_dat) || PyTuple_CheckExact(__pyx_v_dat)) { __pyx_t_3 = __pyx_v_dat; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_dat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; } for (;;) { if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_point, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":105 * emp_cdf = [] * for point in dat: * point_cdf = len(dat[dat <= point]) / len(dat) # <<<<<<<<<<<<<< * emp_cdf.append(point_cdf) * return np.array(emp_cdf) */ __pyx_t_1 = PyObject_RichCompare(__pyx_v_dat, __pyx_v_point, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = PyObject_GetItem(__pyx_v_dat, __pyx_t_1); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = PyObject_Length(__pyx_v_dat); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (unlikely(__pyx_t_7 == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); #endif PyErr_Format(PyExc_ZeroDivisionError, "float division"); #ifdef WITH_THREAD PyGILState_Release(__pyx_gilstate_save); #endif {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = PyFloat_FromDouble((((double)__pyx_t_6) / ((double)__pyx_t_7))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_point_cdf, __pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":106 * for point in dat: * point_cdf = len(dat[dat <= point]) / len(dat) * emp_cdf.append(point_cdf) # <<<<<<<<<<<<<< * return np.array(emp_cdf) * */ __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_emp_cdf, __pyx_v_point_cdf); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":107 * point_cdf = len(dat[dat <= point]) / len(dat) * emp_cdf.append(point_cdf) * return np.array(emp_cdf) # <<<<<<<<<<<<<< * * def hist_pmf(xs, pmf, bins): */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_emp_cdf)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_emp_cdf)); __Pyx_GIVEREF(((PyObject *)__pyx_v_emp_cdf)); __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; __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("macroecotools.get_emp_cdf", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_emp_cdf); __Pyx_XDECREF(__pyx_v_point); __Pyx_XDECREF(__pyx_v_point_cdf); __Pyx_XDECREF(__pyx_v_dat); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_13hist_pmf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_12hist_pmf[] = "Create a histogram based on a probability mass function\n\n Creates a histogram by combining the pmf values inside a series of bins\n\n Args:\n xs: Array-like list of x values that the pmf values come from\n pmf: Array-like list of pmf values associate with the values of x\n bins: Array-like list of bin edges\n\n Returns:\n hist: Array of values of the histogram\n bin_edges: Array of value of the bin edges\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_13hist_pmf = {__Pyx_NAMESTR("hist_pmf"), (PyCFunction)__pyx_pw_13macroecotools_13hist_pmf, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_12hist_pmf)}; static PyObject *__pyx_pw_13macroecotools_13hist_pmf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_xs = 0; PyObject *__pyx_v_pmf = 0; PyObject *__pyx_v_bins = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hist_pmf (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__xs,&__pyx_n_s__pmf,&__pyx_n_s__bins,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); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xs)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pmf)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("hist_pmf", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bins)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("hist_pmf", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "hist_pmf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __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_xs = values[0]; __pyx_v_pmf = values[1]; __pyx_v_bins = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("hist_pmf", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.hist_pmf", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_12hist_pmf(__pyx_self, __pyx_v_xs, __pyx_v_pmf, __pyx_v_bins); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":109 * return np.array(emp_cdf) * * def hist_pmf(xs, pmf, bins): # <<<<<<<<<<<<<< * """Create a histogram based on a probability mass function * */ static PyObject *__pyx_pf_13macroecotools_12hist_pmf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_xs, PyObject *__pyx_v_pmf, PyObject *__pyx_v_bins) { PyObject *__pyx_v_hist = NULL; PyObject *__pyx_v_lower_edge_index = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("hist_pmf", 0); __Pyx_INCREF(__pyx_v_xs); __Pyx_INCREF(__pyx_v_pmf); __Pyx_INCREF(__pyx_v_bins); /* "macroecotools.pyx":124 * * """ * xs = np.array(xs) # <<<<<<<<<<<<<< * pmf = np.array(pmf) * bins = np.array(bins) */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_xs); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_xs); __Pyx_GIVEREF(__pyx_v_xs); __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_xs, __pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":125 * """ * xs = np.array(xs) * pmf = np.array(pmf) # <<<<<<<<<<<<<< * bins = np.array(bins) * */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_pmf); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_pmf); __Pyx_GIVEREF(__pyx_v_pmf); __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_pmf, __pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":126 * xs = np.array(xs) * pmf = np.array(pmf) * bins = np.array(bins) # <<<<<<<<<<<<<< * * hist = [] */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_bins); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_bins); __Pyx_GIVEREF(__pyx_v_bins); __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_bins, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":128 * bins = np.array(bins) * * hist = [] # <<<<<<<<<<<<<< * for lower_edge_index in range(len(bins) - 1): * if lower_edge_index + 1 == len(bins): */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_hist = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":129 * * hist = [] * for lower_edge_index in range(len(bins) - 1): # <<<<<<<<<<<<<< * if lower_edge_index + 1 == len(bins): * hist.append(sum(pmf[(xs >= bins[lower_edge_index]) & */ __pyx_t_4 = PyObject_Length(__pyx_v_bins); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_4 - 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_lower_edge_index, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":130 * hist = [] * for lower_edge_index in range(len(bins) - 1): * if lower_edge_index + 1 == len(bins): # <<<<<<<<<<<<<< * hist.append(sum(pmf[(xs >= bins[lower_edge_index]) & * (xs <= bins[lower_edge_index + 1])])) */ __pyx_t_1 = PyNumber_Add(__pyx_v_lower_edge_index, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_Length(__pyx_v_bins); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_8) { /* "macroecotools.pyx":131 * for lower_edge_index in range(len(bins) - 1): * if lower_edge_index + 1 == len(bins): * hist.append(sum(pmf[(xs >= bins[lower_edge_index]) & # <<<<<<<<<<<<<< * (xs <= bins[lower_edge_index + 1])])) * else: */ __pyx_t_7 = PyObject_GetItem(__pyx_v_bins, __pyx_v_lower_edge_index); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = PyObject_RichCompare(__pyx_v_xs, __pyx_t_7, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "macroecotools.pyx":132 * if lower_edge_index + 1 == len(bins): * hist.append(sum(pmf[(xs >= bins[lower_edge_index]) & * (xs <= bins[lower_edge_index + 1])])) # <<<<<<<<<<<<<< * else: * hist.append(sum(pmf[(xs >= bins[lower_edge_index]) & */ __pyx_t_7 = PyNumber_Add(__pyx_v_lower_edge_index, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PyObject_GetItem(__pyx_v_bins, __pyx_t_7); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_RichCompare(__pyx_v_xs, __pyx_t_1, Py_LE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_And(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_GetItem(__pyx_v_pmf, __pyx_t_1); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_hist, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __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; goto __pyx_L5; } /*else*/ { /* "macroecotools.pyx":134 * (xs <= bins[lower_edge_index + 1])])) * else: * hist.append(sum(pmf[(xs >= bins[lower_edge_index]) & # <<<<<<<<<<<<<< * (xs < bins[lower_edge_index + 1])])) * hist = np.array(hist) */ __pyx_t_1 = PyObject_GetItem(__pyx_v_bins, __pyx_v_lower_edge_index); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyObject_RichCompare(__pyx_v_xs, __pyx_t_1, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":135 * else: * hist.append(sum(pmf[(xs >= bins[lower_edge_index]) & * (xs < bins[lower_edge_index + 1])])) # <<<<<<<<<<<<<< * hist = np.array(hist) * return (hist, bins) */ __pyx_t_1 = PyNumber_Add(__pyx_v_lower_edge_index, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyObject_GetItem(__pyx_v_bins, __pyx_t_1); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_RichCompare(__pyx_v_xs, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_And(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_GetItem(__pyx_v_pmf, __pyx_t_3); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Append(__pyx_v_hist, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __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; } __pyx_L5:; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":136 * hist.append(sum(pmf[(xs >= bins[lower_edge_index]) & * (xs < bins[lower_edge_index + 1])])) * hist = np.array(hist) # <<<<<<<<<<<<<< * return (hist, bins) * */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_hist); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_hist); __Pyx_GIVEREF(__pyx_v_hist); __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_hist, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":137 * (xs < bins[lower_edge_index + 1])])) * hist = np.array(hist) * return (hist, bins) # <<<<<<<<<<<<<< * * def plot_rad(Ns): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_hist); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_hist); __Pyx_GIVEREF(__pyx_v_hist); __Pyx_INCREF(__pyx_v_bins); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_bins); __Pyx_GIVEREF(__pyx_v_bins); __pyx_r = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; __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_7); __Pyx_AddTraceback("macroecotools.hist_pmf", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_hist); __Pyx_XDECREF(__pyx_v_lower_edge_index); __Pyx_XDECREF(__pyx_v_xs); __Pyx_XDECREF(__pyx_v_pmf); __Pyx_XDECREF(__pyx_v_bins); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_15plot_rad(PyObject *__pyx_self, PyObject *__pyx_v_Ns); /*proto*/ static char __pyx_doc_13macroecotools_14plot_rad[] = "Plot a rank-abundance distribution based on a vector of abundances"; static PyMethodDef __pyx_mdef_13macroecotools_15plot_rad = {__Pyx_NAMESTR("plot_rad"), (PyCFunction)__pyx_pw_13macroecotools_15plot_rad, METH_O, __Pyx_DOCSTR(__pyx_doc_13macroecotools_14plot_rad)}; static PyObject *__pyx_pw_13macroecotools_15plot_rad(PyObject *__pyx_self, PyObject *__pyx_v_Ns) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plot_rad (wrapper)", 0); __pyx_r = __pyx_pf_13macroecotools_14plot_rad(__pyx_self, ((PyObject *)__pyx_v_Ns)); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":139 * return (hist, bins) * * def plot_rad(Ns): # <<<<<<<<<<<<<< * """Plot a rank-abundance distribution based on a vector of abundances""" * Ns.sort(reverse=True) */ static PyObject *__pyx_pf_13macroecotools_14plot_rad(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_Ns) { PyObject *__pyx_v_rank = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("plot_rad", 0); /* "macroecotools.pyx":141 * def plot_rad(Ns): * """Plot a rank-abundance distribution based on a vector of abundances""" * Ns.sort(reverse=True) # <<<<<<<<<<<<<< * rank = range(1, len(Ns) + 1) * plt.plot(rank, Ns, 'bo-') */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ns, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reverse), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":142 * """Plot a rank-abundance distribution based on a vector of abundances""" * Ns.sort(reverse=True) * rank = range(1, len(Ns) + 1) # <<<<<<<<<<<<<< * plt.plot(rank, Ns, 'bo-') * plt.xlabel('Rank') */ __pyx_t_4 = PyObject_Length(__pyx_v_Ns); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = PyInt_FromSsize_t((__pyx_t_4 + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_rank = __pyx_t_3; __pyx_t_3 = 0; /* "macroecotools.pyx":143 * Ns.sort(reverse=True) * rank = range(1, len(Ns) + 1) * plt.plot(rank, Ns, 'bo-') # <<<<<<<<<<<<<< * plt.xlabel('Rank') * plt.ylabel('Abundance') */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__plt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__plot); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_rank); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_rank); __Pyx_GIVEREF(__pyx_v_rank); __Pyx_INCREF(__pyx_v_Ns); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_Ns); __Pyx_GIVEREF(__pyx_v_Ns); __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_kp_s_1)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1)); __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":144 * rank = range(1, len(Ns) + 1) * plt.plot(rank, Ns, 'bo-') * plt.xlabel('Rank') # <<<<<<<<<<<<<< * plt.ylabel('Abundance') * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__plt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__xlabel); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __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; /* "macroecotools.pyx":145 * plt.plot(rank, Ns, 'bo-') * plt.xlabel('Rank') * plt.ylabel('Abundance') # <<<<<<<<<<<<<< * * def get_rad_data(Ns): */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__plt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__ylabel); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __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; __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("macroecotools.plot_rad", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_rank); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_17get_rad_data(PyObject *__pyx_self, PyObject *__pyx_v_Ns); /*proto*/ static char __pyx_doc_13macroecotools_16get_rad_data[] = "Provide ranks and relative abundances for a vector of abundances"; static PyMethodDef __pyx_mdef_13macroecotools_17get_rad_data = {__Pyx_NAMESTR("get_rad_data"), (PyCFunction)__pyx_pw_13macroecotools_17get_rad_data, METH_O, __Pyx_DOCSTR(__pyx_doc_13macroecotools_16get_rad_data)}; static PyObject *__pyx_pw_13macroecotools_17get_rad_data(PyObject *__pyx_self, PyObject *__pyx_v_Ns) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_rad_data (wrapper)", 0); __pyx_r = __pyx_pf_13macroecotools_16get_rad_data(__pyx_self, ((PyObject *)__pyx_v_Ns)); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":147 * plt.ylabel('Abundance') * * def get_rad_data(Ns): # <<<<<<<<<<<<<< * """Provide ranks and relative abundances for a vector of abundances""" * Ns = np.array(Ns) */ static PyObject *__pyx_pf_13macroecotools_16get_rad_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_Ns) { PyObject *__pyx_v_Ns_sorted = NULL; PyObject *__pyx_v_relab_sorted = NULL; PyObject *__pyx_v_rank = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_rad_data", 0); __Pyx_INCREF(__pyx_v_Ns); /* "macroecotools.pyx":149 * def get_rad_data(Ns): * """Provide ranks and relative abundances for a vector of abundances""" * Ns = np.array(Ns) # <<<<<<<<<<<<<< * Ns_sorted = -1 * np.sort(-1 * Ns) * relab_sorted = Ns_sorted / sum(Ns_sorted) */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_Ns); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_Ns); __Pyx_GIVEREF(__pyx_v_Ns); __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_Ns, __pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":150 * """Provide ranks and relative abundances for a vector of abundances""" * Ns = np.array(Ns) * Ns_sorted = -1 * np.sort(-1 * Ns) # <<<<<<<<<<<<<< * relab_sorted = Ns_sorted / sum(Ns_sorted) * rank = range(1, len(Ns) + 1) */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__sort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Multiply(__pyx_int_neg_1, __pyx_v_Ns); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Multiply(__pyx_int_neg_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_Ns_sorted = __pyx_t_2; __pyx_t_2 = 0; /* "macroecotools.pyx":151 * Ns = np.array(Ns) * Ns_sorted = -1 * np.sort(-1 * Ns) * relab_sorted = Ns_sorted / sum(Ns_sorted) # <<<<<<<<<<<<<< * rank = range(1, len(Ns) + 1) * return (rank, relab_sorted) */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_Ns_sorted); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_Ns_sorted); __Pyx_GIVEREF(__pyx_v_Ns_sorted); __pyx_t_3 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_v_Ns_sorted, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_relab_sorted = __pyx_t_2; __pyx_t_2 = 0; /* "macroecotools.pyx":152 * Ns_sorted = -1 * np.sort(-1 * Ns) * relab_sorted = Ns_sorted / sum(Ns_sorted) * rank = range(1, len(Ns) + 1) # <<<<<<<<<<<<<< * return (rank, relab_sorted) * */ __pyx_t_4 = PyObject_Length(__pyx_v_Ns); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_4 + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_rank = __pyx_t_2; __pyx_t_2 = 0; /* "macroecotools.pyx":153 * relab_sorted = Ns_sorted / sum(Ns_sorted) * rank = range(1, len(Ns) + 1) * return (rank, relab_sorted) # <<<<<<<<<<<<<< * * def preston_sad(abund_vector, b=None, normalized = 'no'): */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_rank); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_rank); __Pyx_GIVEREF(__pyx_v_rank); __Pyx_INCREF(__pyx_v_relab_sorted); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_relab_sorted); __Pyx_GIVEREF(__pyx_v_relab_sorted); __pyx_r = ((PyObject *)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; __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("macroecotools.get_rad_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_Ns_sorted); __Pyx_XDECREF(__pyx_v_relab_sorted); __Pyx_XDECREF(__pyx_v_rank); __Pyx_XDECREF(__pyx_v_Ns); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_19preston_sad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_18preston_sad[] = "Plot histogram of species abundances on a log2 scale"; static PyMethodDef __pyx_mdef_13macroecotools_19preston_sad = {__Pyx_NAMESTR("preston_sad"), (PyCFunction)__pyx_pw_13macroecotools_19preston_sad, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_18preston_sad)}; static PyObject *__pyx_pw_13macroecotools_19preston_sad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_abund_vector = 0; PyObject *__pyx_v_b = 0; PyObject *__pyx_v_normalized = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("preston_sad (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__abund_vector,&__pyx_n_s__b,&__pyx_n_s__normalized,0}; PyObject* values[3] = {0,0,0}; /* "macroecotools.pyx":155 * return (rank, relab_sorted) * * def preston_sad(abund_vector, b=None, normalized = 'no'): # <<<<<<<<<<<<<< * """Plot histogram of species abundances on a log2 scale""" * if b == None: */ values[1] = ((PyObject *)Py_None); values[2] = ((PyObject *)__pyx_n_s__no); 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); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__abund_vector)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__normalized); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "preston_sad") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_abund_vector = values[0]; __pyx_v_b = values[1]; __pyx_v_normalized = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("preston_sad", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.preston_sad", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_18preston_sad(__pyx_self, __pyx_v_abund_vector, __pyx_v_b, __pyx_v_normalized); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_13macroecotools_18preston_sad(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_abund_vector, PyObject *__pyx_v_b, PyObject *__pyx_v_normalized) { PyObject *__pyx_v_q = NULL; PyObject *__pyx_v_hist_ab = NULL; PyObject *__pyx_v_hist_ab_norm = NULL; PyObject *__pyx_v_hist_ab_norm1 = NULL; PyObject *__pyx_v_hist_ab_norm2 = 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; Py_ssize_t __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("preston_sad", 0); __Pyx_INCREF(__pyx_v_b); /* "macroecotools.pyx":157 * def preston_sad(abund_vector, b=None, normalized = 'no'): * """Plot histogram of species abundances on a log2 scale""" * if b == None: # <<<<<<<<<<<<<< * q = np.exp2(list(range(0, 25))) * b = q [(q <= max(abund_vector)*2)] */ __pyx_t_1 = PyObject_RichCompare(__pyx_v_b, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* "macroecotools.pyx":158 * """Plot histogram of species abundances on a log2 scale""" * if b == None: * q = np.exp2(list(range(0, 25))) # <<<<<<<<<<<<<< * b = q [(q <= max(abund_vector)*2)] * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__exp2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __pyx_v_q = __pyx_t_1; __pyx_t_1 = 0; /* "macroecotools.pyx":159 * if b == None: * q = np.exp2(list(range(0, 25))) * b = q [(q <= max(abund_vector)*2)] # <<<<<<<<<<<<<< * * if normalized == 'no': */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_abund_vector); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_abund_vector); __Pyx_GIVEREF(__pyx_v_abund_vector); __pyx_t_4 = PyObject_Call(__pyx_builtin_max, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Multiply(__pyx_t_4, __pyx_int_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_RichCompare(__pyx_v_q, __pyx_t_1, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_GetItem(__pyx_v_q, __pyx_t_4); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_b, __pyx_t_1); __pyx_t_1 = 0; goto __pyx_L3; } __pyx_L3:; /* "macroecotools.pyx":161 * b = q [(q <= max(abund_vector)*2)] * * if normalized == 'no': # <<<<<<<<<<<<<< * hist_ab = np.histogram(abund_vector, bins = b) * if normalized == 'yes': */ __pyx_t_1 = PyObject_RichCompare(__pyx_v_normalized, ((PyObject *)__pyx_n_s__no), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* "macroecotools.pyx":162 * * if normalized == 'no': * hist_ab = np.histogram(abund_vector, bins = b) # <<<<<<<<<<<<<< * if normalized == 'yes': * hist_ab_norm = np.histogram(abund_vector, bins = b) */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__histogram); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_abund_vector); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_abund_vector); __Pyx_GIVEREF(__pyx_v_abund_vector); __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__bins), __pyx_v_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_hist_ab = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L4; } __pyx_L4:; /* "macroecotools.pyx":163 * if normalized == 'no': * hist_ab = np.histogram(abund_vector, bins = b) * if normalized == 'yes': # <<<<<<<<<<<<<< * hist_ab_norm = np.histogram(abund_vector, bins = b) * hist_ab_norm1 = hist_ab_norm[0]/(b[0:len(hist_ab_norm[0])]) */ __pyx_t_5 = PyObject_RichCompare(__pyx_v_normalized, ((PyObject *)__pyx_n_s__yes), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_2) { /* "macroecotools.pyx":164 * hist_ab = np.histogram(abund_vector, bins = b) * if normalized == 'yes': * hist_ab_norm = np.histogram(abund_vector, bins = b) # <<<<<<<<<<<<<< * hist_ab_norm1 = hist_ab_norm[0]/(b[0:len(hist_ab_norm[0])]) * hist_ab_norm2 = hist_ab_norm[1][0:len(hist_ab_norm[0])] */ __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__histogram); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_abund_vector); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_abund_vector); __Pyx_GIVEREF(__pyx_v_abund_vector); __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bins), __pyx_v_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_hist_ab_norm = __pyx_t_4; __pyx_t_4 = 0; /* "macroecotools.pyx":165 * if normalized == 'yes': * hist_ab_norm = np.histogram(abund_vector, bins = b) * hist_ab_norm1 = hist_ab_norm[0]/(b[0:len(hist_ab_norm[0])]) # <<<<<<<<<<<<<< * hist_ab_norm2 = hist_ab_norm[1][0:len(hist_ab_norm[0])] * hist_ab = (hist_ab_norm1, hist_ab_norm2) */ __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_hist_ab_norm, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_hist_ab_norm, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_b, 0, __pyx_t_6, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_hist_ab_norm1 = __pyx_t_5; __pyx_t_5 = 0; /* "macroecotools.pyx":166 * hist_ab_norm = np.histogram(abund_vector, bins = b) * hist_ab_norm1 = hist_ab_norm[0]/(b[0:len(hist_ab_norm[0])]) * hist_ab_norm2 = hist_ab_norm[1][0:len(hist_ab_norm[0])] # <<<<<<<<<<<<<< * hist_ab = (hist_ab_norm1, hist_ab_norm2) * return hist_ab */ __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_hist_ab_norm, 1, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_hist_ab_norm, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, __pyx_t_6, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_hist_ab_norm2 = __pyx_t_1; __pyx_t_1 = 0; /* "macroecotools.pyx":167 * hist_ab_norm1 = hist_ab_norm[0]/(b[0:len(hist_ab_norm[0])]) * hist_ab_norm2 = hist_ab_norm[1][0:len(hist_ab_norm[0])] * hist_ab = (hist_ab_norm1, hist_ab_norm2) # <<<<<<<<<<<<<< * return hist_ab * */ __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_hist_ab_norm1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_hist_ab_norm1); __Pyx_GIVEREF(__pyx_v_hist_ab_norm1); __Pyx_INCREF(__pyx_v_hist_ab_norm2); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_hist_ab_norm2); __Pyx_GIVEREF(__pyx_v_hist_ab_norm2); __Pyx_XDECREF_SET(__pyx_v_hist_ab, ((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; goto __pyx_L5; } __pyx_L5:; /* "macroecotools.pyx":168 * hist_ab_norm2 = hist_ab_norm[1][0:len(hist_ab_norm[0])] * hist_ab = (hist_ab_norm1, hist_ab_norm2) * return hist_ab # <<<<<<<<<<<<<< * * def plot_SARs(list_of_A_and_S): */ __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_hist_ab)) { __Pyx_RaiseUnboundLocalError("hist_ab"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_INCREF(__pyx_v_hist_ab); __pyx_r = __pyx_v_hist_ab; goto __pyx_L0; __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_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("macroecotools.preston_sad", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_q); __Pyx_XDECREF(__pyx_v_hist_ab); __Pyx_XDECREF(__pyx_v_hist_ab_norm); __Pyx_XDECREF(__pyx_v_hist_ab_norm1); __Pyx_XDECREF(__pyx_v_hist_ab_norm2); __Pyx_XDECREF(__pyx_v_b); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_21plot_SARs(PyObject *__pyx_self, PyObject *__pyx_v_list_of_A_and_S); /*proto*/ static char __pyx_doc_13macroecotools_20plot_SARs[] = "Plot multiple SARs on a single plot.\n\n Input: a list of lists, each sublist contains one vector for S and one vector for A.\n Output: a graph with SARs plotted on log-log scale, with colors spanning the spectrum.\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_21plot_SARs = {__Pyx_NAMESTR("plot_SARs"), (PyCFunction)__pyx_pw_13macroecotools_21plot_SARs, METH_O, __Pyx_DOCSTR(__pyx_doc_13macroecotools_20plot_SARs)}; static PyObject *__pyx_pw_13macroecotools_21plot_SARs(PyObject *__pyx_self, PyObject *__pyx_v_list_of_A_and_S) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plot_SARs (wrapper)", 0); __pyx_r = __pyx_pf_13macroecotools_20plot_SARs(__pyx_self, ((PyObject *)__pyx_v_list_of_A_and_S)); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_9plot_SARs_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ static PyMethodDef __pyx_mdef_13macroecotools_9plot_SARs_lambda1 = {__Pyx_NAMESTR("lambda1"), (PyCFunction)__pyx_pw_13macroecotools_9plot_SARs_lambda1, METH_O, __Pyx_DOCSTR(0)}; static PyObject *__pyx_pw_13macroecotools_9plot_SARs_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_x) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lambda1 (wrapper)", 0); __pyx_r = __pyx_lambda_funcdef_lambda1(__pyx_self, ((PyObject *)__pyx_v_x)); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":179 * N = len(list_of_A_and_S) * HSV_tuples = [(x * 1.0 / N, 0.5, 0.5) for x in range(N)] * RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples) # <<<<<<<<<<<<<< * for i in range(len(list_of_A_and_S)): * sublist = list_of_A_and_S[i] */ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x) { 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("lambda1", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__colorsys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__hsv_to_rgb); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PySequence_Tuple(__pyx_v_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; __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("macroecotools.plot_SARs.lambda1", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":170 * return hist_ab * * def plot_SARs(list_of_A_and_S): # <<<<<<<<<<<<<< * """Plot multiple SARs on a single plot. * */ static PyObject *__pyx_pf_13macroecotools_20plot_SARs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_list_of_A_and_S) { PyObject *__pyx_v_N = NULL; PyObject *__pyx_v_HSV_tuples = NULL; PyObject *__pyx_v_RGB_tuples = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_sublist = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *(*__pyx_t_5)(PyObject *); 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("plot_SARs", 0); /* "macroecotools.pyx":177 * * """ * N = len(list_of_A_and_S) # <<<<<<<<<<<<<< * HSV_tuples = [(x * 1.0 / N, 0.5, 0.5) for x in range(N)] * RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples) */ __pyx_t_1 = PyObject_Length(__pyx_v_list_of_A_and_S); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_N = __pyx_t_2; __pyx_t_2 = 0; /* "macroecotools.pyx":178 * """ * N = len(list_of_A_and_S) * HSV_tuples = [(x * 1.0 / N, 0.5, 0.5) for x in range(N)] # <<<<<<<<<<<<<< * RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples) * for i in range(len(list_of_A_and_S)): */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_N); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_N); __Pyx_GIVEREF(__pyx_v_N); __pyx_t_4 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) { __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; __pyx_t_5 = NULL; } else { __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; for (;;) { if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_4 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_4)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyNumber_Multiply(__pyx_v_x, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_v_N); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_HSV_tuples = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":179 * N = len(list_of_A_and_S) * HSV_tuples = [(x * 1.0 / N, 0.5, 0.5) for x in range(N)] * RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples) # <<<<<<<<<<<<<< * for i in range(len(list_of_A_and_S)): * sublist = list_of_A_and_S[i] */ __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_13macroecotools_9plot_SARs_lambda1, 0, __pyx_n_s_5, NULL, __pyx_n_s__macroecotools, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_HSV_tuples)); PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_HSV_tuples)); __Pyx_GIVEREF(((PyObject *)__pyx_v_HSV_tuples)); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_RGB_tuples = __pyx_t_2; __pyx_t_2 = 0; /* "macroecotools.pyx":180 * HSV_tuples = [(x * 1.0 / N, 0.5, 0.5) for x in range(N)] * RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples) * for i in range(len(list_of_A_and_S)): # <<<<<<<<<<<<<< * sublist = list_of_A_and_S[i] * plt.loglog(sublist[0], sublist[1], color = RGB_tuples[i]) */ __pyx_t_1 = PyObject_Length(__pyx_v_list_of_A_and_S); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; __pyx_t_5 = NULL; } else { __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":181 * RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples) * for i in range(len(list_of_A_and_S)): * sublist = list_of_A_and_S[i] # <<<<<<<<<<<<<< * plt.loglog(sublist[0], sublist[1], color = RGB_tuples[i]) * plt.hold(False) */ __pyx_t_2 = PyObject_GetItem(__pyx_v_list_of_A_and_S, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_sublist, __pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":182 * for i in range(len(list_of_A_and_S)): * sublist = list_of_A_and_S[i] * plt.loglog(sublist[0], sublist[1], color = RGB_tuples[i]) # <<<<<<<<<<<<<< * plt.hold(False) * plt.xlabel('Area') */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__plt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__loglog); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_sublist, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_sublist, 1, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_2 = 0; __pyx_t_7 = 0; __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_7)); __pyx_t_2 = PyObject_GetItem(__pyx_v_RGB_tuples, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__color), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":183 * sublist = list_of_A_and_S[i] * plt.loglog(sublist[0], sublist[1], color = RGB_tuples[i]) * plt.hold(False) # <<<<<<<<<<<<<< * plt.xlabel('Area') * plt.ylabel('Richness') */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__plt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__hold); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":184 * plt.loglog(sublist[0], sublist[1], color = RGB_tuples[i]) * plt.hold(False) * plt.xlabel('Area') # <<<<<<<<<<<<<< * plt.ylabel('Richness') * */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__plt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__xlabel); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":185 * plt.hold(False) * plt.xlabel('Area') * plt.ylabel('Richness') # <<<<<<<<<<<<<< * * def count_pts_within_radius(x, y, radius, logscale=0): */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__plt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__ylabel); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __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_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("macroecotools.plot_SARs", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_N); __Pyx_XDECREF(__pyx_v_HSV_tuples); __Pyx_XDECREF(__pyx_v_RGB_tuples); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_sublist); __Pyx_XDECREF(__pyx_v_x); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_23count_pts_within_radius(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_22count_pts_within_radius[] = "Count the number of points within a fixed radius in 2D space"; static PyMethodDef __pyx_mdef_13macroecotools_23count_pts_within_radius = {__Pyx_NAMESTR("count_pts_within_radius"), (PyCFunction)__pyx_pw_13macroecotools_23count_pts_within_radius, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_22count_pts_within_radius)}; static PyObject *__pyx_pw_13macroecotools_23count_pts_within_radius(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_x = 0; PyObject *__pyx_v_y = 0; PyObject *__pyx_v_radius = 0; PyObject *__pyx_v_logscale = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("count_pts_within_radius (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__radius,&__pyx_n_s__logscale,0}; PyObject* values[4] = {0,0,0,0}; values[3] = ((PyObject *)__pyx_int_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); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("count_pts_within_radius", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__radius)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("count_pts_within_radius", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__logscale); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "count_pts_within_radius") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); 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_x = values[0]; __pyx_v_y = values[1]; __pyx_v_radius = values[2]; __pyx_v_logscale = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("count_pts_within_radius", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.count_pts_within_radius", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_22count_pts_within_radius(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_radius, __pyx_v_logscale); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":187 * plt.ylabel('Richness') * * def count_pts_within_radius(x, y, radius, logscale=0): # <<<<<<<<<<<<<< * """Count the number of points within a fixed radius in 2D space""" * #TODO: see if we can improve performance using KDTree.query_ball_point */ static PyObject *__pyx_pf_13macroecotools_22count_pts_within_radius(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_radius, PyObject *__pyx_v_logscale) { PyObject *__pyx_v_raw_data = NULL; PyObject *__pyx_v_unique_points = NULL; PyObject *__pyx_v_xval = NULL; PyObject *__pyx_v_yval = NULL; PyObject *__pyx_v_count_data = NULL; PyObject *__pyx_v_a = NULL; PyObject *__pyx_v_b = NULL; PyObject *__pyx_v_num_neighbors = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *(*__pyx_t_8)(PyObject *); 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("count_pts_within_radius", 0); __Pyx_INCREF(__pyx_v_x); __Pyx_INCREF(__pyx_v_y); /* "macroecotools.pyx":192 * #http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.KDTree.query_ball_point.html * #instead of doing the subset based on the circle * raw_data = np.array([x, y]) # <<<<<<<<<<<<<< * x = np.array(x) * y = np.array(y) */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_x); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); __Pyx_INCREF(__pyx_v_y); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_raw_data = __pyx_t_1; __pyx_t_1 = 0; /* "macroecotools.pyx":193 * #instead of doing the subset based on the circle * raw_data = np.array([x, y]) * x = np.array(x) # <<<<<<<<<<<<<< * y = np.array(y) * raw_data = raw_data.transpose() */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":194 * raw_data = np.array([x, y]) * x = np.array(x) * y = np.array(y) # <<<<<<<<<<<<<< * raw_data = raw_data.transpose() * */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_y); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_y, __pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":195 * x = np.array(x) * y = np.array(y) * raw_data = raw_data.transpose() # <<<<<<<<<<<<<< * * # Get unique data points by adding each pair of points to a set */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_raw_data, __pyx_n_s__transpose); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_raw_data, __pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":198 * * # Get unique data points by adding each pair of points to a set * unique_points = set() # <<<<<<<<<<<<<< * for xval, yval in raw_data: * unique_points.add((xval, yval)) */ __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __pyx_v_unique_points = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":199 * # Get unique data points by adding each pair of points to a set * unique_points = set() * for xval, yval in raw_data: # <<<<<<<<<<<<<< * unique_points.add((xval, yval)) * */ if (PyList_CheckExact(__pyx_v_raw_data) || PyTuple_CheckExact(__pyx_v_raw_data)) { __pyx_t_2 = __pyx_v_raw_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_raw_data); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; } for (;;) { if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_3); } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_xval, __pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF_SET(__pyx_v_yval, __pyx_t_6); __pyx_t_6 = 0; /* "macroecotools.pyx":200 * unique_points = set() * for xval, yval in raw_data: * unique_points.add((xval, yval)) # <<<<<<<<<<<<<< * * count_data = [] */ __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_xval); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_xval); __Pyx_GIVEREF(__pyx_v_xval); __Pyx_INCREF(__pyx_v_yval); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_yval); __Pyx_GIVEREF(__pyx_v_yval); __pyx_t_9 = PySet_Add(__pyx_v_unique_points, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":202 * unique_points.add((xval, yval)) * * count_data = [] # <<<<<<<<<<<<<< * for a, b in unique_points: * if logscale == 1: */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_count_data = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":203 * * count_data = [] * for a, b in unique_points: # <<<<<<<<<<<<<< * if logscale == 1: * num_neighbors = len(x[((log10(x) - log10(a)) ** 2 + */ __pyx_t_2 = PyObject_GetIter(((PyObject *)__pyx_v_unique_points)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; for (;;) { { __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_3); } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; index = 0; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L10_unpacking_done; __pyx_L9_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L10_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_b, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":204 * count_data = [] * for a, b in unique_points: * if logscale == 1: # <<<<<<<<<<<<<< * num_neighbors = len(x[((log10(x) - log10(a)) ** 2 + * (log10(y) - log10(b)) ** 2) <= log10(radius) ** 2]) */ __pyx_t_3 = PyObject_RichCompare(__pyx_v_logscale, __pyx_int_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_10) { /* "macroecotools.pyx":205 * for a, b in unique_points: * if logscale == 1: * num_neighbors = len(x[((log10(x) - log10(a)) ** 2 + # <<<<<<<<<<<<<< * (log10(y) - log10(b)) ** 2) <= log10(radius) ** 2]) * else: */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__log10); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__log10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_a); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_a); __Pyx_GIVEREF(__pyx_v_a); __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Subtract(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyNumber_Power(__pyx_t_3, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":206 * if logscale == 1: * num_neighbors = len(x[((log10(x) - log10(a)) ** 2 + * (log10(y) - log10(b)) ** 2) <= log10(radius) ** 2]) # <<<<<<<<<<<<<< * else: * num_neighbors = len(x[((x - a) ** 2 + (y - b) ** 2) <= radius ** 2]) */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__log10); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_y); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__log10); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_b); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_b); __Pyx_GIVEREF(__pyx_v_b); __pyx_t_11 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyNumber_Power(__pyx_t_3, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s__log10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_radius); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_radius); __Pyx_GIVEREF(__pyx_v_radius); __pyx_t_1 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __pyx_t_7 = PyNumber_Power(__pyx_t_1, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_7, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_GetItem(__pyx_v_x, __pyx_t_1); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = PyObject_Length(__pyx_t_7); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_XDECREF_SET(__pyx_v_num_neighbors, __pyx_t_7); __pyx_t_7 = 0; goto __pyx_L11; } /*else*/ { /* "macroecotools.pyx":208 * (log10(y) - log10(b)) ** 2) <= log10(radius) ** 2]) * else: * num_neighbors = len(x[((x - a) ** 2 + (y - b) ** 2) <= radius ** 2]) # <<<<<<<<<<<<<< * count_data.append((a, b, num_neighbors)) * return count_data */ __pyx_t_7 = PyNumber_Subtract(__pyx_v_x, __pyx_v_a); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PyNumber_Power(__pyx_t_7, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyNumber_Subtract(__pyx_v_y, __pyx_v_b); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = PyNumber_Power(__pyx_t_7, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Power(__pyx_v_radius, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyObject_RichCompare(__pyx_t_7, __pyx_t_3, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_GetItem(__pyx_v_x, __pyx_t_1); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_num_neighbors, __pyx_t_3); __pyx_t_3 = 0; } __pyx_L11:; /* "macroecotools.pyx":209 * else: * num_neighbors = len(x[((x - a) ** 2 + (y - b) ** 2) <= radius ** 2]) * count_data.append((a, b, num_neighbors)) # <<<<<<<<<<<<<< * return count_data * */ __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_a); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_a); __Pyx_GIVEREF(__pyx_v_a); __Pyx_INCREF(__pyx_v_b); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_b); __Pyx_GIVEREF(__pyx_v_b); __Pyx_INCREF(__pyx_v_num_neighbors); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_num_neighbors); __Pyx_GIVEREF(__pyx_v_num_neighbors); __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_count_data, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":210 * num_neighbors = len(x[((x - a) ** 2 + (y - b) ** 2) <= radius ** 2]) * count_data.append((a, b, num_neighbors)) * return count_data # <<<<<<<<<<<<<< * * def plot_color_by_pt_dens(x, y, radius, loglog=0, plot_obj=None): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_count_data)); __pyx_r = ((PyObject *)__pyx_v_count_data); goto __pyx_L0; __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_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("macroecotools.count_pts_within_radius", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_raw_data); __Pyx_XDECREF(__pyx_v_unique_points); __Pyx_XDECREF(__pyx_v_xval); __Pyx_XDECREF(__pyx_v_yval); __Pyx_XDECREF(__pyx_v_count_data); __Pyx_XDECREF(__pyx_v_a); __Pyx_XDECREF(__pyx_v_b); __Pyx_XDECREF(__pyx_v_num_neighbors); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_y); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_25plot_color_by_pt_dens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_24plot_color_by_pt_dens[] = "Plot bivariate relationships with large n using color for point density\n\n Inputs:\n x & y -- variables to be plotted\n radius -- the linear distance within which to count points as neighbors\n loglog -- a flag to indicate the use of a loglog plot (loglog = 1)\n\n The color of each point in the plot is determined by the logarithm (base 10)\n of the number of points that occur with a given radius of the focal point,\n with hotter colors indicating more points. The number of neighboring points\n is determined in linear space regardless of whether a loglog plot is\n presented.\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_25plot_color_by_pt_dens = {__Pyx_NAMESTR("plot_color_by_pt_dens"), (PyCFunction)__pyx_pw_13macroecotools_25plot_color_by_pt_dens, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_24plot_color_by_pt_dens)}; static PyObject *__pyx_pw_13macroecotools_25plot_color_by_pt_dens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_x = 0; PyObject *__pyx_v_y = 0; PyObject *__pyx_v_radius = 0; PyObject *__pyx_v_loglog = 0; PyObject *__pyx_v_plot_obj = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plot_color_by_pt_dens (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__radius,&__pyx_n_s__loglog,&__pyx_n_s__plot_obj,0}; PyObject* values[5] = {0,0,0,0,0}; values[3] = ((PyObject *)__pyx_int_0); /* "macroecotools.pyx":212 * return count_data * * def plot_color_by_pt_dens(x, y, radius, loglog=0, plot_obj=None): # <<<<<<<<<<<<<< * """Plot bivariate relationships with large n using color for point density * */ values[4] = ((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 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("plot_color_by_pt_dens", 0, 3, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__radius)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("plot_color_by_pt_dens", 0, 3, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__loglog); if (value) { values[3] = value; kw_args--; } } case 4: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__plot_obj); if (value) { values[4] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "plot_color_by_pt_dens") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); 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_x = values[0]; __pyx_v_y = values[1]; __pyx_v_radius = values[2]; __pyx_v_loglog = values[3]; __pyx_v_plot_obj = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("plot_color_by_pt_dens", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.plot_color_by_pt_dens", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_24plot_color_by_pt_dens(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_radius, __pyx_v_loglog, __pyx_v_plot_obj); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_21plot_color_by_pt_dens_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_point); /*proto*/ static PyMethodDef __pyx_mdef_13macroecotools_21plot_color_by_pt_dens_lambda2 = {__Pyx_NAMESTR("lambda2"), (PyCFunction)__pyx_pw_13macroecotools_21plot_color_by_pt_dens_lambda2, METH_O, __Pyx_DOCSTR(0)}; static PyObject *__pyx_pw_13macroecotools_21plot_color_by_pt_dens_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_point) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lambda2 (wrapper)", 0); __pyx_r = __pyx_lambda_funcdef_lambda2(__pyx_self, ((PyObject *)__pyx_v_point)); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":228 * """ * plot_data = count_pts_within_radius(x, y, radius, loglog) * sorted_plot_data = np.array(sorted(plot_data, key=lambda point: point[2])) # <<<<<<<<<<<<<< * * if plot_obj == None: */ static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_point) { 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("lambda2", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_point, 2, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("macroecotools.plot_color_by_pt_dens.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":212 * return count_data * * def plot_color_by_pt_dens(x, y, radius, loglog=0, plot_obj=None): # <<<<<<<<<<<<<< * """Plot bivariate relationships with large n using color for point density * */ static PyObject *__pyx_pf_13macroecotools_24plot_color_by_pt_dens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_radius, PyObject *__pyx_v_loglog, PyObject *__pyx_v_plot_obj) { PyObject *__pyx_v_plot_data = NULL; PyObject *__pyx_v_sorted_plot_data = 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; PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("plot_color_by_pt_dens", 0); __Pyx_INCREF(__pyx_v_plot_obj); /* "macroecotools.pyx":227 * * """ * plot_data = count_pts_within_radius(x, y, radius, loglog) # <<<<<<<<<<<<<< * sorted_plot_data = np.array(sorted(plot_data, key=lambda point: point[2])) * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); __Pyx_INCREF(__pyx_v_y); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); __Pyx_INCREF(__pyx_v_radius); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_radius); __Pyx_GIVEREF(__pyx_v_radius); __Pyx_INCREF(__pyx_v_loglog); PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_loglog); __Pyx_GIVEREF(__pyx_v_loglog); __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_plot_data = __pyx_t_3; __pyx_t_3 = 0; /* "macroecotools.pyx":228 * """ * plot_data = count_pts_within_radius(x, y, radius, loglog) * sorted_plot_data = np.array(sorted(plot_data, key=lambda point: point[2])) # <<<<<<<<<<<<<< * * if plot_obj == None: */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_plot_data); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_plot_data); __Pyx_GIVEREF(__pyx_v_plot_data); __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_13macroecotools_21plot_color_by_pt_dens_lambda2, 0, __pyx_n_s_9, NULL, __pyx_n_s__macroecotools, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__key), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_sorted_plot_data = __pyx_t_4; __pyx_t_4 = 0; /* "macroecotools.pyx":230 * sorted_plot_data = np.array(sorted(plot_data, key=lambda point: point[2])) * * if plot_obj == None: # <<<<<<<<<<<<<< * plot_obj = plt.axes() * */ __pyx_t_4 = PyObject_RichCompare(__pyx_v_plot_obj, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { /* "macroecotools.pyx":231 * * if plot_obj == None: * plot_obj = plt.axes() # <<<<<<<<<<<<<< * * if loglog == 1: */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__plt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__axes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_plot_obj, __pyx_t_4); __pyx_t_4 = 0; goto __pyx_L3; } __pyx_L3:; /* "macroecotools.pyx":233 * plot_obj = plt.axes() * * if loglog == 1: # <<<<<<<<<<<<<< * plot_obj.set_xscale('log') * plot_obj.set_yscale('log') */ __pyx_t_4 = PyObject_RichCompare(__pyx_v_loglog, __pyx_int_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { /* "macroecotools.pyx":234 * * if loglog == 1: * plot_obj.set_xscale('log') # <<<<<<<<<<<<<< * plot_obj.set_yscale('log') * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_plot_obj, __pyx_n_s__set_xscale); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __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; /* "macroecotools.pyx":235 * if loglog == 1: * plot_obj.set_xscale('log') * plot_obj.set_yscale('log') # <<<<<<<<<<<<<< * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], * c = np.sqrt(sorted_plot_data[:, 2]), edgecolors='none') */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_plot_obj, __pyx_n_s__set_yscale); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "macroecotools.pyx":236 * plot_obj.set_xscale('log') * plot_obj.set_yscale('log') * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], # <<<<<<<<<<<<<< * c = np.sqrt(sorted_plot_data[:, 2]), edgecolors='none') * plot_obj.set_xlim(min(x) * 0.5, max(x) * 2) */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_plot_obj, __pyx_n_s__scatter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyObject_GetItem(__pyx_v_sorted_plot_data, ((PyObject *)__pyx_k_tuple_13)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_GetItem(__pyx_v_sorted_plot_data, ((PyObject *)__pyx_k_tuple_15)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); /* "macroecotools.pyx":237 * plot_obj.set_yscale('log') * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], * c = np.sqrt(sorted_plot_data[:, 2]), edgecolors='none') # <<<<<<<<<<<<<< * plot_obj.set_xlim(min(x) * 0.5, max(x) * 2) * plot_obj.set_ylim(min(y) * 0.5, max(y) * 2) */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__sqrt); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_GetItem(__pyx_v_sorted_plot_data, ((PyObject *)__pyx_k_tuple_17)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__c), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__edgecolors), ((PyObject *)__pyx_n_s__none)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":238 * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], * c = np.sqrt(sorted_plot_data[:, 2]), edgecolors='none') * plot_obj.set_xlim(min(x) * 0.5, max(x) * 2) # <<<<<<<<<<<<<< * plot_obj.set_ylim(min(y) * 0.5, max(y) * 2) * else: */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_plot_obj, __pyx_n_s__set_xlim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); __pyx_t_3 = PyObject_Call(__pyx_builtin_min, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __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_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_x); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); __pyx_t_3 = PyObject_Call(__pyx_builtin_max, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Multiply(__pyx_t_3, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":239 * c = np.sqrt(sorted_plot_data[:, 2]), edgecolors='none') * plot_obj.set_xlim(min(x) * 0.5, max(x) * 2) * plot_obj.set_ylim(min(y) * 0.5, max(y) * 2) # <<<<<<<<<<<<<< * else: * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plot_obj, __pyx_n_s__set_ylim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_y); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); __pyx_t_1 = PyObject_Call(__pyx_builtin_min, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_y); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); __pyx_t_1 = PyObject_Call(__pyx_builtin_max, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_int_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L4; } /*else*/ { /* "macroecotools.pyx":241 * plot_obj.set_ylim(min(y) * 0.5, max(y) * 2) * else: * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], # <<<<<<<<<<<<<< * c = log10(sorted_plot_data[:, 2]), edgecolors='none') * return plot_obj */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_plot_obj, __pyx_n_s__scatter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyObject_GetItem(__pyx_v_sorted_plot_data, ((PyObject *)__pyx_k_tuple_19)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_GetItem(__pyx_v_sorted_plot_data, ((PyObject *)__pyx_k_tuple_21)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); /* "macroecotools.pyx":242 * else: * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], * c = log10(sorted_plot_data[:, 2]), edgecolors='none') # <<<<<<<<<<<<<< * return plot_obj * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__log10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyObject_GetItem(__pyx_v_sorted_plot_data, ((PyObject *)__pyx_k_tuple_23)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__c), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__edgecolors), ((PyObject *)__pyx_n_s__none)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_L4:; /* "macroecotools.pyx":243 * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], * c = log10(sorted_plot_data[:, 2]), edgecolors='none') * return plot_obj # <<<<<<<<<<<<<< * * def e_var(abundance_data): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_plot_obj); __pyx_r = __pyx_v_plot_obj; goto __pyx_L0; __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_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("macroecotools.plot_color_by_pt_dens", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_plot_data); __Pyx_XDECREF(__pyx_v_sorted_plot_data); __Pyx_XDECREF(__pyx_v_plot_obj); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_27e_var(PyObject *__pyx_self, PyObject *__pyx_v_abundance_data); /*proto*/ static char __pyx_doc_13macroecotools_26e_var[] = "Calculate Smith and Wilson's (1996; Oikos 76:70-82) evenness index (Evar)\n\n Input:\n abundance_data = list of abundance fo all species in a community\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_27e_var = {__Pyx_NAMESTR("e_var"), (PyCFunction)__pyx_pw_13macroecotools_27e_var, METH_O, __Pyx_DOCSTR(__pyx_doc_13macroecotools_26e_var)}; static PyObject *__pyx_pw_13macroecotools_27e_var(PyObject *__pyx_self, PyObject *__pyx_v_abundance_data) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("e_var (wrapper)", 0); __pyx_r = __pyx_pf_13macroecotools_26e_var(__pyx_self, ((PyObject *)__pyx_v_abundance_data)); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":245 * return plot_obj * * def e_var(abundance_data): # <<<<<<<<<<<<<< * """Calculate Smith and Wilson's (1996; Oikos 76:70-82) evenness index (Evar) * */ static PyObject *__pyx_pf_13macroecotools_26e_var(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_abundance_data) { PyObject *__pyx_v_S = NULL; PyObject *__pyx_v_ln_nj_over_S = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_v1 = NULL; PyObject *__pyx_v_ln_ni_minus_above = NULL; PyObject *__pyx_v_v2 = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *(*__pyx_t_4)(PyObject *); PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("e_var", 0); /* "macroecotools.pyx":252 * * """ * S = len(abundance_data) # <<<<<<<<<<<<<< * ln_nj_over_S=[] * for i in range(0, S): */ __pyx_t_1 = PyObject_Length(__pyx_v_abundance_data); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_S = __pyx_t_2; __pyx_t_2 = 0; /* "macroecotools.pyx":253 * """ * S = len(abundance_data) * ln_nj_over_S=[] # <<<<<<<<<<<<<< * for i in range(0, S): * v1 = (np.log(abundance_data[i]))/S */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_ln_nj_over_S = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":254 * S = len(abundance_data) * ln_nj_over_S=[] * for i in range(0, S): # <<<<<<<<<<<<<< * v1 = (np.log(abundance_data[i]))/S * ln_nj_over_S.append(v1) */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_INCREF(__pyx_v_S); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_S); __Pyx_GIVEREF(__pyx_v_S); __pyx_t_3 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0; __pyx_t_4 = NULL; } else { __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_3 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":255 * ln_nj_over_S=[] * for i in range(0, S): * v1 = (np.log(abundance_data[i]))/S # <<<<<<<<<<<<<< * ln_nj_over_S.append(v1) * */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__log); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_GetItem(__pyx_v_abundance_data, __pyx_v_i); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_S); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_v1, __pyx_t_6); __pyx_t_6 = 0; /* "macroecotools.pyx":256 * for i in range(0, S): * v1 = (np.log(abundance_data[i]))/S * ln_nj_over_S.append(v1) # <<<<<<<<<<<<<< * * ln_ni_minus_above=[] */ __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_ln_nj_over_S, __pyx_v_v1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":258 * ln_nj_over_S.append(v1) * * ln_ni_minus_above=[] # <<<<<<<<<<<<<< * for i in range(0, S): * v2 = ((np.log(abundance_data[i])) - sum(ln_nj_over_S)) ** 2 */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_ln_ni_minus_above = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":259 * * ln_ni_minus_above=[] * for i in range(0, S): # <<<<<<<<<<<<<< * v2 = ((np.log(abundance_data[i])) - sum(ln_nj_over_S)) ** 2 * ln_ni_minus_above.append(v2) */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_INCREF(__pyx_v_S); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_S); __Pyx_GIVEREF(__pyx_v_S); __pyx_t_6 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) { __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0; __pyx_t_4 = NULL; } else { __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; for (;;) { if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_6 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_6); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6); __pyx_t_6 = 0; /* "macroecotools.pyx":260 * ln_ni_minus_above=[] * for i in range(0, S): * v2 = ((np.log(abundance_data[i])) - sum(ln_nj_over_S)) ** 2 # <<<<<<<<<<<<<< * ln_ni_minus_above.append(v2) * */ __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__log); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyObject_GetItem(__pyx_v_abundance_data, __pyx_v_i); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(((PyObject *)__pyx_v_ln_nj_over_S)); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_ln_nj_over_S)); __Pyx_GIVEREF(((PyObject *)__pyx_v_ln_nj_over_S)); __pyx_t_3 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __pyx_t_5 = PyNumber_Subtract(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Power(__pyx_t_5, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_v2, __pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":261 * for i in range(0, S): * v2 = ((np.log(abundance_data[i])) - sum(ln_nj_over_S)) ** 2 * ln_ni_minus_above.append(v2) # <<<<<<<<<<<<<< * * return(1 - ((2 / np.pi) * np.arctan(sum(ln_ni_minus_above) / S))) */ __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_ln_ni_minus_above, __pyx_v_v2); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":263 * ln_ni_minus_above.append(v2) * * return(1 - ((2 / np.pi) * np.arctan(sum(ln_ni_minus_above) / S))) # <<<<<<<<<<<<<< * * def obs_pred_rsquare(obs, pred): */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__pi); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_int_2, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__arctan); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_ln_ni_minus_above)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_ln_ni_minus_above)); __Pyx_GIVEREF(((PyObject *)__pyx_v_ln_ni_minus_above)); __pyx_t_6 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_v_S); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Multiply(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Subtract(__pyx_int_1, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; __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_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("macroecotools.e_var", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_S); __Pyx_XDECREF(__pyx_v_ln_nj_over_S); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_v1); __Pyx_XDECREF(__pyx_v_ln_ni_minus_above); __Pyx_XDECREF(__pyx_v_v2); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_29obs_pred_rsquare(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_28obs_pred_rsquare[] = "Determines the prop of variability in a data set accounted for by a model\n\n In other words, this determines the proportion of variation explained by\n the 1:1 line in an observed-predicted plot.\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_29obs_pred_rsquare = {__Pyx_NAMESTR("obs_pred_rsquare"), (PyCFunction)__pyx_pw_13macroecotools_29obs_pred_rsquare, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_28obs_pred_rsquare)}; static PyObject *__pyx_pw_13macroecotools_29obs_pred_rsquare(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_obs = 0; PyObject *__pyx_v_pred = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("obs_pred_rsquare (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__obs,&__pyx_n_s__pred,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); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obs)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pred)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("obs_pred_rsquare", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "obs_pred_rsquare") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __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_obs = values[0]; __pyx_v_pred = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("obs_pred_rsquare", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.obs_pred_rsquare", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_28obs_pred_rsquare(__pyx_self, __pyx_v_obs, __pyx_v_pred); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":265 * return(1 - ((2 / np.pi) * np.arctan(sum(ln_ni_minus_above) / S))) * * def obs_pred_rsquare(obs, pred): # <<<<<<<<<<<<<< * """Determines the prop of variability in a data set accounted for by a model * */ static PyObject *__pyx_pf_13macroecotools_28obs_pred_rsquare(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obs, PyObject *__pyx_v_pred) { 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_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("obs_pred_rsquare", 0); /* "macroecotools.pyx":272 * * """ * return 1 - sum((obs - pred) ** 2) / sum((obs - np.mean(obs)) ** 2) # <<<<<<<<<<<<<< * * def obs_pred_mse(obs, pred): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyNumber_Subtract(__pyx_v_obs, __pyx_v_pred); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Power(__pyx_t_1, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__mean); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_obs); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_obs); __Pyx_GIVEREF(__pyx_v_obs); __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Subtract(__pyx_v_obs, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Power(__pyx_t_1, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; __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_AddTraceback("macroecotools.obs_pred_rsquare", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_31obs_pred_mse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_30obs_pred_mse[] = "Calculate the mean squared error of the prediction given observation."; static PyMethodDef __pyx_mdef_13macroecotools_31obs_pred_mse = {__Pyx_NAMESTR("obs_pred_mse"), (PyCFunction)__pyx_pw_13macroecotools_31obs_pred_mse, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_30obs_pred_mse)}; static PyObject *__pyx_pw_13macroecotools_31obs_pred_mse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_obs = 0; PyObject *__pyx_v_pred = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("obs_pred_mse (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__obs,&__pyx_n_s__pred,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); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obs)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pred)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("obs_pred_mse", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "obs_pred_mse") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __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_obs = values[0]; __pyx_v_pred = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("obs_pred_mse", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.obs_pred_mse", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_30obs_pred_mse(__pyx_self, __pyx_v_obs, __pyx_v_pred); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":274 * return 1 - sum((obs - pred) ** 2) / sum((obs - np.mean(obs)) ** 2) * * def obs_pred_mse(obs, pred): # <<<<<<<<<<<<<< * """Calculate the mean squared error of the prediction given observation.""" * */ static PyObject *__pyx_pf_13macroecotools_30obs_pred_mse(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obs, PyObject *__pyx_v_pred) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; Py_ssize_t __pyx_t_3; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("obs_pred_mse", 0); /* "macroecotools.pyx":277 * """Calculate the mean squared error of the prediction given observation.""" * * return sum((obs - pred) ** 2) / len(obs) # <<<<<<<<<<<<<< * * def comp_ed (spdata1,abdata1,spdata2,abdata2): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyNumber_Subtract(__pyx_v_obs, __pyx_v_pred); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Power(__pyx_t_1, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_3 = PyObject_Length(__pyx_v_obs); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; __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_4); __Pyx_AddTraceback("macroecotools.obs_pred_mse", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_33comp_ed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_32comp_ed[] = "Calculate the compositional Euclidean Distance between two sites\n\n Ref: Thibault KM, White EP, Ernest SKM. 2004. Temporal dynamics in the\n structure and composition of a desert rodent community. Ecology. 85:2649-2655.\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_33comp_ed = {__Pyx_NAMESTR("comp_ed"), (PyCFunction)__pyx_pw_13macroecotools_33comp_ed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_32comp_ed)}; static PyObject *__pyx_pw_13macroecotools_33comp_ed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_spdata1 = 0; PyObject *__pyx_v_abdata1 = 0; PyObject *__pyx_v_spdata2 = 0; PyObject *__pyx_v_abdata2 = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("comp_ed (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__spdata1,&__pyx_n_s__abdata1,&__pyx_n_s__spdata2,&__pyx_n_s__abdata2,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); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__spdata1)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__abdata1)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("comp_ed", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__spdata2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("comp_ed", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__abdata2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("comp_ed", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "comp_ed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __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_spdata1 = values[0]; __pyx_v_abdata1 = values[1]; __pyx_v_spdata2 = values[2]; __pyx_v_abdata2 = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("comp_ed", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.comp_ed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_32comp_ed(__pyx_self, __pyx_v_spdata1, __pyx_v_abdata1, __pyx_v_spdata2, __pyx_v_abdata2); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":279 * return sum((obs - pred) ** 2) / len(obs) * * def comp_ed (spdata1,abdata1,spdata2,abdata2): # <<<<<<<<<<<<<< * """Calculate the compositional Euclidean Distance between two sites * */ static PyObject *__pyx_pf_13macroecotools_32comp_ed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_spdata1, PyObject *__pyx_v_abdata1, PyObject *__pyx_v_spdata2, PyObject *__pyx_v_abdata2) { PyObject *__pyx_v_intersect12 = NULL; PyObject *__pyx_v_setdiff12 = NULL; PyObject *__pyx_v_setdiff21 = NULL; PyObject *__pyx_v_relab1 = NULL; PyObject *__pyx_v_relab2 = 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; Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("comp_ed", 0); __Pyx_INCREF(__pyx_v_abdata1); __Pyx_INCREF(__pyx_v_abdata2); /* "macroecotools.pyx":286 * * """ * abdata1 = (abdata1 * 1.0) / sum(abdata1) # <<<<<<<<<<<<<< * abdata2 = (abdata2 * 1.0) / sum(abdata2) * intersect12 = set(spdata1).intersection(spdata2) */ __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Multiply(__pyx_v_abdata1, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_abdata1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_abdata1); __Pyx_GIVEREF(__pyx_v_abdata1); __pyx_t_3 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __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_DECREF_SET(__pyx_v_abdata1, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":287 * """ * abdata1 = (abdata1 * 1.0) / sum(abdata1) * abdata2 = (abdata2 * 1.0) / sum(abdata2) # <<<<<<<<<<<<<< * intersect12 = set(spdata1).intersection(spdata2) * setdiff12 = np.setdiff1d(spdata1,spdata2) */ __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyNumber_Multiply(__pyx_v_abdata2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_abdata2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_abdata2); __Pyx_GIVEREF(__pyx_v_abdata2); __pyx_t_2 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_abdata2, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":288 * abdata1 = (abdata1 * 1.0) / sum(abdata1) * abdata2 = (abdata2 * 1.0) / sum(abdata2) * intersect12 = set(spdata1).intersection(spdata2) # <<<<<<<<<<<<<< * setdiff12 = np.setdiff1d(spdata1,spdata2) * setdiff21 = np.setdiff1d(spdata2,spdata1) */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_spdata1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_spdata1); __Pyx_GIVEREF(__pyx_v_spdata1); __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PySet_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__intersection); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_spdata2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_spdata2); __Pyx_GIVEREF(__pyx_v_spdata2); __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_intersect12 = __pyx_t_3; __pyx_t_3 = 0; /* "macroecotools.pyx":289 * abdata2 = (abdata2 * 1.0) / sum(abdata2) * intersect12 = set(spdata1).intersection(spdata2) * setdiff12 = np.setdiff1d(spdata1,spdata2) # <<<<<<<<<<<<<< * setdiff21 = np.setdiff1d(spdata2,spdata1) * relab1 = np.concatenate(((abdata1[np.setmember1d(spdata1,list(intersect12)) == 1]), */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__setdiff1d); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_spdata1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_spdata1); __Pyx_GIVEREF(__pyx_v_spdata1); __Pyx_INCREF(__pyx_v_spdata2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_spdata2); __Pyx_GIVEREF(__pyx_v_spdata2); __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_setdiff12 = __pyx_t_1; __pyx_t_1 = 0; /* "macroecotools.pyx":290 * intersect12 = set(spdata1).intersection(spdata2) * setdiff12 = np.setdiff1d(spdata1,spdata2) * setdiff21 = np.setdiff1d(spdata2,spdata1) # <<<<<<<<<<<<<< * relab1 = np.concatenate(((abdata1[np.setmember1d(spdata1,list(intersect12)) == 1]), * abdata1[np.setmember1d(spdata1,setdiff12)], */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__setdiff1d); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_spdata2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_spdata2); __Pyx_GIVEREF(__pyx_v_spdata2); __Pyx_INCREF(__pyx_v_spdata1); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_spdata1); __Pyx_GIVEREF(__pyx_v_spdata1); __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_setdiff21 = __pyx_t_2; __pyx_t_2 = 0; /* "macroecotools.pyx":291 * setdiff12 = np.setdiff1d(spdata1,spdata2) * setdiff21 = np.setdiff1d(spdata2,spdata1) * relab1 = np.concatenate(((abdata1[np.setmember1d(spdata1,list(intersect12)) == 1]), # <<<<<<<<<<<<<< * abdata1[np.setmember1d(spdata1,setdiff12)], * np.zeros(len(setdiff21)))) */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__concatenate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__setmember1d); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_intersect12); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_intersect12); __Pyx_GIVEREF(__pyx_v_intersect12); __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_spdata1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_spdata1); __Pyx_GIVEREF(__pyx_v_spdata1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_int_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_GetItem(__pyx_v_abdata1, __pyx_t_2); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":292 * setdiff21 = np.setdiff1d(spdata2,spdata1) * relab1 = np.concatenate(((abdata1[np.setmember1d(spdata1,list(intersect12)) == 1]), * abdata1[np.setmember1d(spdata1,setdiff12)], # <<<<<<<<<<<<<< * np.zeros(len(setdiff21)))) * relab2 = np.concatenate((abdata2[np.setmember1d(spdata2,list(intersect12)) == 1], */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__setmember1d); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_spdata1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_spdata1); __Pyx_GIVEREF(__pyx_v_spdata1); __Pyx_INCREF(__pyx_v_setdiff12); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_setdiff12); __Pyx_GIVEREF(__pyx_v_setdiff12); __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = PyObject_GetItem(__pyx_v_abdata1, __pyx_t_5); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "macroecotools.pyx":293 * relab1 = np.concatenate(((abdata1[np.setmember1d(spdata1,list(intersect12)) == 1]), * abdata1[np.setmember1d(spdata1,setdiff12)], * np.zeros(len(setdiff21)))) # <<<<<<<<<<<<<< * relab2 = np.concatenate((abdata2[np.setmember1d(spdata2,list(intersect12)) == 1], * np.zeros(len(setdiff12)), */ __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = PyObject_Length(__pyx_v_setdiff21); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_7)); __Pyx_GIVEREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __pyx_v_relab1 = __pyx_t_7; __pyx_t_7 = 0; /* "macroecotools.pyx":294 * abdata1[np.setmember1d(spdata1,setdiff12)], * np.zeros(len(setdiff21)))) * relab2 = np.concatenate((abdata2[np.setmember1d(spdata2,list(intersect12)) == 1], # <<<<<<<<<<<<<< * np.zeros(len(setdiff12)), * abdata2[np.setmember1d(spdata2,setdiff21)])) */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s__concatenate); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s__setmember1d); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_intersect12); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_intersect12); __Pyx_GIVEREF(__pyx_v_intersect12); __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_spdata2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_spdata2); __Pyx_GIVEREF(__pyx_v_spdata2); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, __pyx_int_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_GetItem(__pyx_v_abdata2, __pyx_t_7); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "macroecotools.pyx":295 * np.zeros(len(setdiff21)))) * relab2 = np.concatenate((abdata2[np.setmember1d(spdata2,list(intersect12)) == 1], * np.zeros(len(setdiff12)), # <<<<<<<<<<<<<< * abdata2[np.setmember1d(spdata2,setdiff21)])) * return np.sqrt(sum((relab1 - relab2) ** 2)) */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s__zeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_6 = PyObject_Length(__pyx_v_setdiff12); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; /* "macroecotools.pyx":296 * relab2 = np.concatenate((abdata2[np.setmember1d(spdata2,list(intersect12)) == 1], * np.zeros(len(setdiff12)), * abdata2[np.setmember1d(spdata2,setdiff21)])) # <<<<<<<<<<<<<< * return np.sqrt(sum((relab1 - relab2) ** 2)) * */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__setmember1d); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_spdata2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_spdata2); __Pyx_GIVEREF(__pyx_v_spdata2); __Pyx_INCREF(__pyx_v_setdiff21); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_setdiff21); __Pyx_GIVEREF(__pyx_v_setdiff21); __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __pyx_t_4 = PyObject_GetItem(__pyx_v_abdata2, __pyx_t_3); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_2 = 0; __pyx_t_7 = 0; __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __pyx_v_relab2 = __pyx_t_3; __pyx_t_3 = 0; /* "macroecotools.pyx":297 * np.zeros(len(setdiff12)), * abdata2[np.setmember1d(spdata2,setdiff21)])) * return np.sqrt(sum((relab1 - relab2) ** 2)) # <<<<<<<<<<<<<< * * def calc_comp_eds(ifile, fout, cutoff=4): */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__sqrt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Subtract(__pyx_v_relab1, __pyx_v_relab2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyNumber_Power(__pyx_t_3, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyObject_Call(__pyx_builtin_sum, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; __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_XDECREF(__pyx_t_7); __Pyx_AddTraceback("macroecotools.comp_ed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_intersect12); __Pyx_XDECREF(__pyx_v_setdiff12); __Pyx_XDECREF(__pyx_v_setdiff21); __Pyx_XDECREF(__pyx_v_relab1); __Pyx_XDECREF(__pyx_v_relab2); __Pyx_XDECREF(__pyx_v_abdata1); __Pyx_XDECREF(__pyx_v_abdata2); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_35calc_comp_eds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_34calc_comp_eds[] = "Calculate Euclidean distances in species composition across sites.\n\n Determines the Euclidean distances among all possible pairs of sites and\n saves the results to a file\n\n Inputs:\n ifile -- ifile = np.genfromtxt(input_filename, dtype = \"S15,S15,i8\",\n names = ['site','species','ab'], delimiter = \",\")\n fout -- fout = csv.writer(open(output_filename,'ab'))\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_35calc_comp_eds = {__Pyx_NAMESTR("calc_comp_eds"), (PyCFunction)__pyx_pw_13macroecotools_35calc_comp_eds, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_34calc_comp_eds)}; static PyObject *__pyx_pw_13macroecotools_35calc_comp_eds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_ifile = 0; PyObject *__pyx_v_fout = 0; PyObject *__pyx_v_cutoff = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("calc_comp_eds (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__ifile,&__pyx_n_s__fout,&__pyx_n_s__cutoff,0}; PyObject* values[3] = {0,0,0}; values[2] = ((PyObject *)__pyx_int_4); 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); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ifile)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fout)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("calc_comp_eds", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cutoff); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "calc_comp_eds") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); 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_ifile = values[0]; __pyx_v_fout = values[1]; __pyx_v_cutoff = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("calc_comp_eds", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.calc_comp_eds", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_34calc_comp_eds(__pyx_self, __pyx_v_ifile, __pyx_v_fout, __pyx_v_cutoff); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":299 * return np.sqrt(sum((relab1 - relab2) ** 2)) * * def calc_comp_eds(ifile, fout, cutoff=4): # <<<<<<<<<<<<<< * """Calculate Euclidean distances in species composition across sites. * */ static PyObject *__pyx_pf_13macroecotools_34calc_comp_eds(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ifile, PyObject *__pyx_v_fout, PyObject *__pyx_v_cutoff) { PyObject *__pyx_v_usites = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_spdata1 = NULL; PyObject *__pyx_v_abdata1 = NULL; PyObject *__pyx_v_a = NULL; PyObject *__pyx_v_spdata2 = NULL; PyObject *__pyx_v_abdata2 = NULL; PyObject *__pyx_v_ed = NULL; PyObject *__pyx_v_results = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; Py_ssize_t __pyx_t_8; PyObject *(*__pyx_t_9)(PyObject *); PyObject *__pyx_t_10 = NULL; Py_ssize_t __pyx_t_11; int __pyx_t_12; int __pyx_t_13; int __pyx_t_14; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("calc_comp_eds", 0); /* "macroecotools.pyx":315 * # Return result rather than writing to file * * usites = np.sort(list(set(ifile["site"]))) # <<<<<<<<<<<<<< * * for i in range (0, len(usites)-1): */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_GetItem(__pyx_v_ifile, ((PyObject *)__pyx_n_s__site)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PySet_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_usites = __pyx_t_1; __pyx_t_1 = 0; /* "macroecotools.pyx":317 * usites = np.sort(list(set(ifile["site"]))) * * for i in range (0, len(usites)-1): # <<<<<<<<<<<<<< * spdata1 = ifile["species"][ifile["site"] == usites[i]] * abdata1 = ifile["ab"][ifile["site"] == usites[i]] */ __pyx_t_4 = PyObject_Length(__pyx_v_usites); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_4 - 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":318 * * for i in range (0, len(usites)-1): * spdata1 = ifile["species"][ifile["site"] == usites[i]] # <<<<<<<<<<<<<< * abdata1 = ifile["ab"][ifile["site"] == usites[i]] * */ __pyx_t_1 = PyObject_GetItem(__pyx_v_ifile, ((PyObject *)__pyx_n_s__species)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_GetItem(__pyx_v_ifile, ((PyObject *)__pyx_n_s__site)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyObject_GetItem(__pyx_v_usites, __pyx_v_i); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_spdata1, __pyx_t_6); __pyx_t_6 = 0; /* "macroecotools.pyx":319 * for i in range (0, len(usites)-1): * spdata1 = ifile["species"][ifile["site"] == usites[i]] * abdata1 = ifile["ab"][ifile["site"] == usites[i]] # <<<<<<<<<<<<<< * * for a in range (i+1,len(usites)): */ __pyx_t_6 = PyObject_GetItem(__pyx_v_ifile, ((PyObject *)__pyx_n_s__ab)); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyObject_GetItem(__pyx_v_ifile, ((PyObject *)__pyx_n_s__site)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PyObject_GetItem(__pyx_v_usites, __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_RichCompare(__pyx_t_7, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_GetItem(__pyx_t_6, __pyx_t_2); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_abdata1, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":321 * abdata1 = ifile["ab"][ifile["site"] == usites[i]] * * for a in range (i+1,len(usites)): # <<<<<<<<<<<<<< * spdata2 = ifile["species"][ifile["site"] == usites[a]] * abdata2 = ifile["ab"][ifile["site"] == usites[a]] */ __pyx_t_1 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = PyObject_Length(__pyx_v_usites); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_6)) { if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) { if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_2 = __pyx_t_9(__pyx_t_6); if (unlikely(!__pyx_t_2)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":322 * * for a in range (i+1,len(usites)): * spdata2 = ifile["species"][ifile["site"] == usites[a]] # <<<<<<<<<<<<<< * abdata2 = ifile["ab"][ifile["site"] == usites[a]] * */ __pyx_t_2 = PyObject_GetItem(__pyx_v_ifile, ((PyObject *)__pyx_n_s__species)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_GetItem(__pyx_v_ifile, ((PyObject *)__pyx_n_s__site)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyObject_GetItem(__pyx_v_usites, __pyx_v_a); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = PyObject_RichCompare(__pyx_t_1, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_GetItem(__pyx_t_2, __pyx_t_10); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_spdata2, __pyx_t_7); __pyx_t_7 = 0; /* "macroecotools.pyx":323 * for a in range (i+1,len(usites)): * spdata2 = ifile["species"][ifile["site"] == usites[a]] * abdata2 = ifile["ab"][ifile["site"] == usites[a]] # <<<<<<<<<<<<<< * * if len(spdata1) > cutoff and len(spdata2) > cutoff: */ __pyx_t_7 = PyObject_GetItem(__pyx_v_ifile, ((PyObject *)__pyx_n_s__ab)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = PyObject_GetItem(__pyx_v_ifile, ((PyObject *)__pyx_n_s__site)); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __pyx_t_2 = PyObject_GetItem(__pyx_v_usites, __pyx_v_a); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_RichCompare(__pyx_t_10, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_GetItem(__pyx_t_7, __pyx_t_1); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF_SET(__pyx_v_abdata2, __pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":325 * abdata2 = ifile["ab"][ifile["site"] == usites[a]] * * if len(spdata1) > cutoff and len(spdata2) > cutoff: # <<<<<<<<<<<<<< * ed = comp_ed (spdata1,abdata1,spdata2,abdata2) * results = np.column_stack((usites[i], usites[a], ed)) */ __pyx_t_11 = PyObject_Length(__pyx_v_spdata1); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_v_cutoff, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_12) { __pyx_t_11 = PyObject_Length(__pyx_v_spdata2); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_v_cutoff, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_14 = __pyx_t_13; } else { __pyx_t_14 = __pyx_t_12; } if (__pyx_t_14) { /* "macroecotools.pyx":326 * * if len(spdata1) > cutoff and len(spdata2) > cutoff: * ed = comp_ed (spdata1,abdata1,spdata2,abdata2) # <<<<<<<<<<<<<< * results = np.column_stack((usites[i], usites[a], ed)) * fout.writerows(results) */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__comp_ed); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_spdata1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_spdata1); __Pyx_GIVEREF(__pyx_v_spdata1); __Pyx_INCREF(__pyx_v_abdata1); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_abdata1); __Pyx_GIVEREF(__pyx_v_abdata1); __Pyx_INCREF(__pyx_v_spdata2); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_spdata2); __Pyx_GIVEREF(__pyx_v_spdata2); __Pyx_INCREF(__pyx_v_abdata2); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_abdata2); __Pyx_GIVEREF(__pyx_v_abdata2); __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_XDECREF_SET(__pyx_v_ed, __pyx_t_7); __pyx_t_7 = 0; /* "macroecotools.pyx":327 * if len(spdata1) > cutoff and len(spdata2) > cutoff: * ed = comp_ed (spdata1,abdata1,spdata2,abdata2) * results = np.column_stack((usites[i], usites[a], ed)) # <<<<<<<<<<<<<< * fout.writerows(results) * */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s__column_stack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyObject_GetItem(__pyx_v_usites, __pyx_v_i); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = PyObject_GetItem(__pyx_v_usites, __pyx_v_a); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_ed); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_ed); __Pyx_GIVEREF(__pyx_v_ed); __pyx_t_7 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_10)); __Pyx_GIVEREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_results, __pyx_t_10); __pyx_t_10 = 0; /* "macroecotools.pyx":328 * ed = comp_ed (spdata1,abdata1,spdata2,abdata2) * results = np.column_stack((usites[i], usites[a], ed)) * fout.writerows(results) # <<<<<<<<<<<<<< * * def combined_spID(*species_identifiers): */ __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_fout, __pyx_n_s__writerows); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_results); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_results); __Pyx_GIVEREF(__pyx_v_results); __pyx_t_1 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L7; } __pyx_L7:; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __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_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("macroecotools.calc_comp_eds", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_usites); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_spdata1); __Pyx_XDECREF(__pyx_v_abdata1); __Pyx_XDECREF(__pyx_v_a); __Pyx_XDECREF(__pyx_v_spdata2); __Pyx_XDECREF(__pyx_v_abdata2); __Pyx_XDECREF(__pyx_v_ed); __Pyx_XDECREF(__pyx_v_results); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_37combined_spID(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_36combined_spID[] = "Return a single column unique species identifier\n\n Creates a unique species identifier based on one or more columns of a\n data frame that represent the unique species ID.\n\n Args:\n species_identifiers: A tuple containing one or pieces of a unique\n species identifier or lists of these pieces.\n\n Returns:\n A single unique species identifier or a list of single identifiers\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_37combined_spID = {__Pyx_NAMESTR("combined_spID"), (PyCFunction)__pyx_pw_13macroecotools_37combined_spID, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_36combined_spID)}; static PyObject *__pyx_pw_13macroecotools_37combined_spID(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_species_identifiers = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("combined_spID (wrapper)", 0); if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "combined_spID", 0))) return NULL; __Pyx_INCREF(__pyx_args); __pyx_v_species_identifiers = __pyx_args; __pyx_r = __pyx_pf_13macroecotools_36combined_spID(__pyx_self, __pyx_v_species_identifiers); __Pyx_XDECREF(__pyx_v_species_identifiers); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":330 * fout.writerows(results) * * def combined_spID(*species_identifiers): # <<<<<<<<<<<<<< * """Return a single column unique species identifier * */ static PyObject *__pyx_pf_13macroecotools_36combined_spID(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_species_identifiers) { PyObject *__pyx_v_input_type = NULL; PyObject *__pyx_v_single_identifier = NULL; PyObject *__pyx_v_identifier = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; Py_ssize_t __pyx_t_7; PyObject *(*__pyx_t_8)(PyObject *); PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("combined_spID", 0); __Pyx_INCREF(__pyx_v_species_identifiers); /* "macroecotools.pyx":346 * * # Make standard input data types capable of element wise summation * input_type = type(species_identifiers[0]) # <<<<<<<<<<<<<< * assert input_type in [list, tuple, str, pandas.core.series.Series, numpy.ndarray] * if input_type is not str: */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_species_identifiers, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_t_1))); __pyx_v_input_type = ((PyObject*)((PyObject *)Py_TYPE(__pyx_t_1))); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":347 * # Make standard input data types capable of element wise summation * input_type = type(species_identifiers[0]) * assert input_type in [list, tuple, str, pandas.core.series.Series, numpy.ndarray] # <<<<<<<<<<<<<< * if input_type is not str: * species_identifiers = [pandas.Series(identifier) for identifier in species_identifiers] */ #ifndef CYTHON_WITHOUT_ASSERTIONS __Pyx_INCREF(((PyObject *)__pyx_v_input_type)); __pyx_t_2 = __pyx_v_input_type; __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_t_2), ((PyObject *)((PyObject*)(&PyList_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!((int)__pyx_t_3)) { __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_t_2), ((PyObject *)((PyObject*)(&PyTuple_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = ((int)__pyx_t_4); } else { __pyx_t_5 = ((int)__pyx_t_3); } if (!__pyx_t_5) { __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_t_2), ((PyObject *)((PyObject*)(&PyString_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = ((int)__pyx_t_3); } else { __pyx_t_4 = __pyx_t_5; } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__pandas); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__core); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__series); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__Series); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_t_2), __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = ((int)__pyx_t_5); } else { __pyx_t_3 = __pyx_t_4; } if (!__pyx_t_3) { __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__ndarray); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_t_2), __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = ((int)__pyx_t_4); } else { __pyx_t_5 = __pyx_t_3; } __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_5 != 0))) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #endif /* "macroecotools.pyx":348 * input_type = type(species_identifiers[0]) * assert input_type in [list, tuple, str, pandas.core.series.Series, numpy.ndarray] * if input_type is not str: # <<<<<<<<<<<<<< * species_identifiers = [pandas.Series(identifier) for identifier in species_identifiers] * */ __pyx_t_5 = (__pyx_v_input_type != ((PyObject*)(&PyString_Type))); __pyx_t_3 = (__pyx_t_5 != 0); if (__pyx_t_3) { /* "macroecotools.pyx":349 * assert input_type in [list, tuple, str, pandas.core.series.Series, numpy.ndarray] * if input_type is not str: * species_identifiers = [pandas.Series(identifier) for identifier in species_identifiers] # <<<<<<<<<<<<<< * * single_identifier = species_identifiers[0] */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyList_CheckExact(__pyx_v_species_identifiers) || PyTuple_CheckExact(__pyx_v_species_identifiers)) { __pyx_t_6 = __pyx_v_species_identifiers; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_species_identifiers); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; } for (;;) { if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_6)) { if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_9 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_6)) { if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_9 = __pyx_t_8(__pyx_t_6); if (unlikely(!__pyx_t_9)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_9); } __Pyx_XDECREF_SET(__pyx_v_identifier, __pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__pandas); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s__Series); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_identifier); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_identifier); __Pyx_GIVEREF(__pyx_v_identifier); __pyx_t_11 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_11))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_species_identifiers, ((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; goto __pyx_L3; } __pyx_L3:; /* "macroecotools.pyx":351 * species_identifiers = [pandas.Series(identifier) for identifier in species_identifiers] * * single_identifier = species_identifiers[0] # <<<<<<<<<<<<<< * if len(species_identifiers) > 1: * for identifier in species_identifiers[1:]: */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_species_identifiers, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_single_identifier = __pyx_t_1; __pyx_t_1 = 0; /* "macroecotools.pyx":352 * * single_identifier = species_identifiers[0] * if len(species_identifiers) > 1: # <<<<<<<<<<<<<< * for identifier in species_identifiers[1:]: * single_identifier += identifier */ __pyx_t_7 = PyObject_Length(__pyx_v_species_identifiers); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = ((__pyx_t_7 > 1) != 0); if (__pyx_t_3) { /* "macroecotools.pyx":353 * single_identifier = species_identifiers[0] * if len(species_identifiers) > 1: * for identifier in species_identifiers[1:]: # <<<<<<<<<<<<<< * single_identifier += identifier * if input_type == numpy.ndarray: */ __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_species_identifiers, 1, 0, NULL, NULL, &__pyx_k_slice_24, 1, 0, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_6 = __pyx_t_1; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_6)) { if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_6)) { if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_8(__pyx_t_6); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_identifier, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":354 * if len(species_identifiers) > 1: * for identifier in species_identifiers[1:]: * single_identifier += identifier # <<<<<<<<<<<<<< * if input_type == numpy.ndarray: * single_identifier = numpy.array(single_identifier) */ __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_single_identifier, __pyx_v_identifier); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_single_identifier, __pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6; } __pyx_L6:; /* "macroecotools.pyx":355 * for identifier in species_identifiers[1:]: * single_identifier += identifier * if input_type == numpy.ndarray: # <<<<<<<<<<<<<< * single_identifier = numpy.array(single_identifier) * else: */ __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__ndarray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyObject_RichCompare(((PyObject *)__pyx_v_input_type), __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_3) { /* "macroecotools.pyx":356 * single_identifier += identifier * if input_type == numpy.ndarray: * single_identifier = numpy.array(single_identifier) # <<<<<<<<<<<<<< * else: * single_identifier = input_type(single_identifier) */ __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_single_identifier); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_single_identifier); __Pyx_GIVEREF(__pyx_v_single_identifier); __pyx_t_11 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_single_identifier, __pyx_t_11); __pyx_t_11 = 0; goto __pyx_L9; } /*else*/ { /* "macroecotools.pyx":358 * single_identifier = numpy.array(single_identifier) * else: * single_identifier = input_type(single_identifier) # <<<<<<<<<<<<<< * return single_identifier * */ __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_v_single_identifier); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_single_identifier); __Pyx_GIVEREF(__pyx_v_single_identifier); __pyx_t_6 = PyObject_Call(((PyObject *)__pyx_v_input_type), ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; __Pyx_DECREF_SET(__pyx_v_single_identifier, __pyx_t_6); __pyx_t_6 = 0; } __pyx_L9:; /* "macroecotools.pyx":359 * else: * single_identifier = input_type(single_identifier) * return single_identifier # <<<<<<<<<<<<<< * * def richness_in_group(composition_data, group_cols, spid_cols): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_single_identifier); __pyx_r = __pyx_v_single_identifier; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(((PyObject *)__pyx_t_2)); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("macroecotools.combined_spID", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_species_identifiers); __Pyx_XDECREF(__pyx_v_input_type); __Pyx_XDECREF(__pyx_v_single_identifier); __Pyx_XDECREF(__pyx_v_identifier); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_39richness_in_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_38richness_in_group[] = "Determine the number of species in a grouping (e.g., at each site)\n\n Counts the number of species grouped at one or more levels. For example,\n the number of species occuring at each of a series of sites or in each of\n a series of years.\n\n If a combination of grouping variables is not present in the data, then no\n values will be returned for that combination. In other words, if these\n missing combinations should be treated as zeros, this will need to be\n handled elsewhere.\n\n Args:\n composition_data: A Pandas data frame with one or more columns with\n information on species identity and one or more columns with\n information on the groups, e.g., years or sites.\n group_cols: A list of strings of the names othe columns in\n composition_data that hold the grouping fields.\n spid_cols: A list of strings of the names of the columns in\n composition_data that hold the data on species ID. This could be a\n single column with a unique ID or two columns containing the latin binomial.\n\n Returns:\n A data frame with the grouping fields and the species richness\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_39richness_in_group = {__Pyx_NAMESTR("richness_in_group"), (PyCFunction)__pyx_pw_13macroecotools_39richness_in_group, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_38richness_in_group)}; static PyObject *__pyx_pw_13macroecotools_39richness_in_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_composition_data = 0; PyObject *__pyx_v_group_cols = 0; PyObject *__pyx_v_spid_cols = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("richness_in_group (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__composition_data,&__pyx_n_s__group_cols,&__pyx_n_s__spid_cols,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); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__composition_data)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__group_cols)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("richness_in_group", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__spid_cols)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("richness_in_group", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "richness_in_group") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __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_composition_data = values[0]; __pyx_v_group_cols = values[1]; __pyx_v_spid_cols = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("richness_in_group", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.richness_in_group", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_38richness_in_group(__pyx_self, __pyx_v_composition_data, __pyx_v_group_cols, __pyx_v_spid_cols); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "macroecotools.pyx":361 * return single_identifier * * def richness_in_group(composition_data, group_cols, spid_cols): # <<<<<<<<<<<<<< * """Determine the number of species in a grouping (e.g., at each site) * */ static PyObject *__pyx_pf_13macroecotools_38richness_in_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_composition_data, PyObject *__pyx_v_group_cols, PyObject *__pyx_v_spid_cols) { PyObject *__pyx_v_spid_series = NULL; PyObject *__pyx_v_single_spid = NULL; PyObject *__pyx_v_richness = NULL; PyObject *__pyx_v_spid_col = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; Py_ssize_t __pyx_t_3; PyObject *(*__pyx_t_4)(PyObject *); PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("richness_in_group", 0); /* "macroecotools.pyx":387 * * """ * spid_series = [composition_data[spid_col] for spid_col in spid_cols] # <<<<<<<<<<<<<< * single_spid = combined_spID(*spid_series) * composition_data['_spid'] = single_spid */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyList_CheckExact(__pyx_v_spid_cols) || PyTuple_CheckExact(__pyx_v_spid_cols)) { __pyx_t_2 = __pyx_v_spid_cols; __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_spid_cols); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; } for (;;) { if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __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_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __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_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_5 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_5)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_spid_col, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyObject_GetItem(__pyx_v_composition_data, __pyx_v_spid_col); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_spid_series = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":388 * """ * spid_series = [composition_data[spid_col] for spid_col in spid_cols] * single_spid = combined_spID(*spid_series) # <<<<<<<<<<<<<< * composition_data['_spid'] = single_spid * richness = composition_data.groupby(group_cols)._spid.nunique() */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__combined_spID); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_spid_series)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_single_spid = __pyx_t_5; __pyx_t_5 = 0; /* "macroecotools.pyx":389 * spid_series = [composition_data[spid_col] for spid_col in spid_cols] * single_spid = combined_spID(*spid_series) * composition_data['_spid'] = single_spid # <<<<<<<<<<<<<< * richness = composition_data.groupby(group_cols)._spid.nunique() * richness = richness.reset_index() */ if (PyObject_SetItem(__pyx_v_composition_data, ((PyObject *)__pyx_n_s___spid), __pyx_v_single_spid) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":390 * single_spid = combined_spID(*spid_series) * composition_data['_spid'] = single_spid * richness = composition_data.groupby(group_cols)._spid.nunique() # <<<<<<<<<<<<<< * richness = richness.reset_index() * richness.columns = group_cols + ['richness'] */ __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_composition_data, __pyx_n_s__groupby); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_group_cols); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_group_cols); __Pyx_GIVEREF(__pyx_v_group_cols); __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s___spid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __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__nunique); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_richness = __pyx_t_2; __pyx_t_2 = 0; /* "macroecotools.pyx":391 * composition_data['_spid'] = single_spid * richness = composition_data.groupby(group_cols)._spid.nunique() * richness = richness.reset_index() # <<<<<<<<<<<<<< * richness.columns = group_cols + ['richness'] * del composition_data['_spid'] */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_richness, __pyx_n_s__reset_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_richness, __pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":392 * richness = composition_data.groupby(group_cols)._spid.nunique() * richness = richness.reset_index() * richness.columns = group_cols + ['richness'] # <<<<<<<<<<<<<< * del composition_data['_spid'] * return richness */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_n_s__richness)); PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__richness)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__richness)); __pyx_t_2 = PyNumber_Add(__pyx_v_group_cols, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; if (__Pyx_PyObject_SetAttrStr(__pyx_v_richness, __pyx_n_s__columns, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":393 * richness = richness.reset_index() * richness.columns = group_cols + ['richness'] * del composition_data['_spid'] # <<<<<<<<<<<<<< * return richness * */ if (PyObject_DelItem(__pyx_v_composition_data, ((PyObject *)__pyx_n_s___spid)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":394 * richness.columns = group_cols + ['richness'] * del composition_data['_spid'] * return richness # <<<<<<<<<<<<<< * * def abundance_in_group(composition_data, group_cols, abund_col=None): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_richness); __pyx_r = __pyx_v_richness; goto __pyx_L0; __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_5); __Pyx_AddTraceback("macroecotools.richness_in_group", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_spid_series); __Pyx_XDECREF(__pyx_v_single_spid); __Pyx_XDECREF(__pyx_v_richness); __Pyx_XDECREF(__pyx_v_spid_col); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_13macroecotools_41abundance_in_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_13macroecotools_40abundance_in_group[] = "Determine the number of individuals in a grouping (e.g., at each site)\n\n Counts the number of individuals grouped at one or more levels. For example,\n the number of species occuring at each of a series of sites or in each of\n a series of genus-species combinations.\n\n If a combination of grouping variables is not present in the data, then no\n values will be returned for that combination. In other words, if these\n missing combinations should be treated as zeros, this will need to be\n handled elsewhere.\n\n Args:\n composition_data: A Pandas data frame with one or more columns with\n information on species identity and one or more columns with\n information on the groups, e.g., years or sites, and a column\n containing the abundance value.\n group_cols: A list of strings of the names othe columns in\n composition_data that hold the grouping fields.\n abund_col: A column containing abundance data. If this column is not\n provided then it is assumed that the abundances are to be obtained\n by counting the number of rows in the group (e.g., there is one\n sample per individual in many ecological datasets)\n\n Returns:\n A data frame with the grouping fields and the species richness\n\n "; static PyMethodDef __pyx_mdef_13macroecotools_41abundance_in_group = {__Pyx_NAMESTR("abundance_in_group"), (PyCFunction)__pyx_pw_13macroecotools_41abundance_in_group, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_13macroecotools_40abundance_in_group)}; static PyObject *__pyx_pw_13macroecotools_41abundance_in_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_composition_data = 0; PyObject *__pyx_v_group_cols = 0; PyObject *__pyx_v_abund_col = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("abundance_in_group (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__composition_data,&__pyx_n_s__group_cols,&__pyx_n_s__abund_col,0}; PyObject* values[3] = {0,0,0}; /* "macroecotools.pyx":396 * return richness * * def abundance_in_group(composition_data, group_cols, abund_col=None): # <<<<<<<<<<<<<< * """Determine the number of individuals in a grouping (e.g., at each site) * */ values[2] = ((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 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__composition_data)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__group_cols)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("abundance_in_group", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__abund_col); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "abundance_in_group") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); 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_composition_data = values[0]; __pyx_v_group_cols = values[1]; __pyx_v_abund_col = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("abundance_in_group", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("macroecotools.abundance_in_group", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_13macroecotools_40abundance_in_group(__pyx_self, __pyx_v_composition_data, __pyx_v_group_cols, __pyx_v_abund_col); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_13macroecotools_40abundance_in_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_composition_data, PyObject *__pyx_v_group_cols, PyObject *__pyx_v_abund_col) { PyObject *__pyx_v_abundance = NULL; 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; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("abundance_in_group", 0); /* "macroecotools.pyx":424 * * """ * if abund_col: # <<<<<<<<<<<<<< * abundance = composition_data[group_cols + abund_col].groupby(group_cols).sum() * else: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_abund_col); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "macroecotools.pyx":425 * """ * if abund_col: * abundance = composition_data[group_cols + abund_col].groupby(group_cols).sum() # <<<<<<<<<<<<<< * else: * abundance = composition_data[group_cols].groupby(group_cols).size() */ __pyx_t_2 = PyNumber_Add(__pyx_v_group_cols, __pyx_v_abund_col); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_GetItem(__pyx_v_composition_data, __pyx_t_2); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __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__groupby); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_group_cols); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_group_cols); __Pyx_GIVEREF(__pyx_v_group_cols); __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_abundance = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L3; } /*else*/ { /* "macroecotools.pyx":427 * abundance = composition_data[group_cols + abund_col].groupby(group_cols).sum() * else: * abundance = composition_data[group_cols].groupby(group_cols).size() # <<<<<<<<<<<<<< * abundance = pandas.DataFrame(abundance) * abundance.columns = ['abundance'] */ __pyx_t_4 = PyObject_GetItem(__pyx_v_composition_data, __pyx_v_group_cols); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__groupby); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_group_cols); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_group_cols); __Pyx_GIVEREF(__pyx_v_group_cols); __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_abundance = __pyx_t_2; __pyx_t_2 = 0; } __pyx_L3:; /* "macroecotools.pyx":428 * else: * abundance = composition_data[group_cols].groupby(group_cols).size() * abundance = pandas.DataFrame(abundance) # <<<<<<<<<<<<<< * abundance.columns = ['abundance'] * abundance = abundance.reset_index() */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__pandas); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__DataFrame); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_abundance); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_abundance); __Pyx_GIVEREF(__pyx_v_abundance); __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_abundance, __pyx_t_3); __pyx_t_3 = 0; /* "macroecotools.pyx":429 * abundance = composition_data[group_cols].groupby(group_cols).size() * abundance = pandas.DataFrame(abundance) * abundance.columns = ['abundance'] # <<<<<<<<<<<<<< * abundance = abundance.reset_index() * return abundance */ __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_n_s__abundance)); PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__abundance)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__abundance)); if (__Pyx_PyObject_SetAttrStr(__pyx_v_abundance, __pyx_n_s__columns, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; /* "macroecotools.pyx":430 * abundance = pandas.DataFrame(abundance) * abundance.columns = ['abundance'] * abundance = abundance.reset_index() # <<<<<<<<<<<<<< * return abundance */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_abundance, __pyx_n_s__reset_index); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_abundance, __pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":431 * abundance.columns = ['abundance'] * abundance = abundance.reset_index() * return abundance # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_abundance); __pyx_r = __pyx_v_abundance; goto __pyx_L0; __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_XDECREF(__pyx_t_4); __Pyx_AddTraceback("macroecotools.abundance_in_group", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_abundance); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef __pyx_moduledef = { #if PY_VERSION_HEX < 0x03020000 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, #else PyModuleDef_HEAD_INIT, #endif __Pyx_NAMESTR("macroecotools"), __Pyx_DOCSTR(__pyx_k_25), /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, {&__pyx_n_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 1}, {&__pyx_n_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 1}, {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0}, {&__pyx_n_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 1}, {&__pyx_n_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 1}, {&__pyx_n_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 1}, {&__pyx_n_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 1}, {&__pyx_n_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 1}, {&__pyx_n_s__AIC, __pyx_k__AIC, sizeof(__pyx_k__AIC), 0, 0, 1, 1}, {&__pyx_n_s__AICc, __pyx_k__AICc, sizeof(__pyx_k__AICc), 0, 0, 1, 1}, {&__pyx_n_s__AICc_list, __pyx_k__AICc_list, sizeof(__pyx_k__AICc_list), 0, 0, 1, 1}, {&__pyx_n_s__AICc_min, __pyx_k__AICc_min, sizeof(__pyx_k__AICc_min), 0, 0, 1, 1}, {&__pyx_n_s__AICc_weights, __pyx_k__AICc_weights, sizeof(__pyx_k__AICc_weights), 0, 0, 1, 1}, {&__pyx_n_s__Abundance, __pyx_k__Abundance, sizeof(__pyx_k__Abundance), 0, 0, 1, 1}, {&__pyx_n_s__Area, __pyx_k__Area, sizeof(__pyx_k__Area), 0, 0, 1, 1}, {&__pyx_n_s__DataFrame, __pyx_k__DataFrame, sizeof(__pyx_k__DataFrame), 0, 0, 1, 1}, {&__pyx_n_s__HSV_tuples, __pyx_k__HSV_tuples, sizeof(__pyx_k__HSV_tuples), 0, 0, 1, 1}, {&__pyx_n_s__L, __pyx_k__L, sizeof(__pyx_k__L), 0, 0, 1, 1}, {&__pyx_n_s__N, __pyx_k__N, sizeof(__pyx_k__N), 0, 0, 1, 1}, {&__pyx_n_s__Ns, __pyx_k__Ns, sizeof(__pyx_k__Ns), 0, 0, 1, 1}, {&__pyx_n_s__Ns_sorted, __pyx_k__Ns_sorted, sizeof(__pyx_k__Ns_sorted), 0, 0, 1, 1}, {&__pyx_n_s__RGB_tuples, __pyx_k__RGB_tuples, sizeof(__pyx_k__RGB_tuples), 0, 0, 1, 1}, {&__pyx_n_s__Rank, __pyx_k__Rank, sizeof(__pyx_k__Rank), 0, 0, 1, 1}, {&__pyx_n_s__Richness, __pyx_k__Richness, sizeof(__pyx_k__Richness), 0, 0, 1, 1}, {&__pyx_n_s__S, __pyx_k__S, sizeof(__pyx_k__S), 0, 0, 1, 1}, {&__pyx_n_s__Series, __pyx_k__Series, sizeof(__pyx_k__Series), 0, 0, 1, 1}, {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1}, {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, {&__pyx_n_s___spid, __pyx_k___spid, sizeof(__pyx_k___spid), 0, 0, 1, 1}, {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1}, {&__pyx_n_s__ab, __pyx_k__ab, sizeof(__pyx_k__ab), 0, 0, 1, 1}, {&__pyx_n_s__abdata1, __pyx_k__abdata1, sizeof(__pyx_k__abdata1), 0, 0, 1, 1}, {&__pyx_n_s__abdata2, __pyx_k__abdata2, sizeof(__pyx_k__abdata2), 0, 0, 1, 1}, {&__pyx_n_s__abund_col, __pyx_k__abund_col, sizeof(__pyx_k__abund_col), 0, 0, 1, 1}, {&__pyx_n_s__abund_vector, __pyx_k__abund_vector, sizeof(__pyx_k__abund_vector), 0, 0, 1, 1}, {&__pyx_n_s__abundance, __pyx_k__abundance, sizeof(__pyx_k__abundance), 0, 0, 1, 1}, {&__pyx_n_s__abundance_data, __pyx_k__abundance_data, sizeof(__pyx_k__abundance_data), 0, 0, 1, 1}, {&__pyx_n_s__abundance_in_group, __pyx_k__abundance_in_group, sizeof(__pyx_k__abundance_in_group), 0, 0, 1, 1}, {&__pyx_n_s__aic_weight, __pyx_k__aic_weight, sizeof(__pyx_k__aic_weight), 0, 0, 1, 1}, {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1}, {&__pyx_n_s__arctan, __pyx_k__arctan, sizeof(__pyx_k__arctan), 0, 0, 1, 1}, {&__pyx_n_s__args, __pyx_k__args, sizeof(__pyx_k__args), 0, 0, 1, 1}, {&__pyx_n_s__array, __pyx_k__array, sizeof(__pyx_k__array), 0, 0, 1, 1}, {&__pyx_n_s__axes, __pyx_k__axes, sizeof(__pyx_k__axes), 0, 0, 1, 1}, {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1}, {&__pyx_n_s__bins, __pyx_k__bins, sizeof(__pyx_k__bins), 0, 0, 1, 1}, {&__pyx_n_s__c, __pyx_k__c, sizeof(__pyx_k__c), 0, 0, 1, 1}, {&__pyx_n_s__calc_comp_eds, __pyx_k__calc_comp_eds, sizeof(__pyx_k__calc_comp_eds), 0, 0, 1, 1}, {&__pyx_n_s__cdf_cum, __pyx_k__cdf_cum, sizeof(__pyx_k__cdf_cum), 0, 0, 1, 1}, {&__pyx_n_s__cdf_obs, __pyx_k__cdf_obs, sizeof(__pyx_k__cdf_obs), 0, 0, 1, 1}, {&__pyx_n_s__color, __pyx_k__color, sizeof(__pyx_k__color), 0, 0, 1, 1}, {&__pyx_n_s__colorsys, __pyx_k__colorsys, sizeof(__pyx_k__colorsys), 0, 0, 1, 1}, {&__pyx_n_s__column_stack, __pyx_k__column_stack, sizeof(__pyx_k__column_stack), 0, 0, 1, 1}, {&__pyx_n_s__columns, __pyx_k__columns, sizeof(__pyx_k__columns), 0, 0, 1, 1}, {&__pyx_n_s__combined_spID, __pyx_k__combined_spID, sizeof(__pyx_k__combined_spID), 0, 0, 1, 1}, {&__pyx_n_s__comp_ed, __pyx_k__comp_ed, sizeof(__pyx_k__comp_ed), 0, 0, 1, 1}, {&__pyx_n_s__composition_data, __pyx_k__composition_data, sizeof(__pyx_k__composition_data), 0, 0, 1, 1}, {&__pyx_n_s__concatenate, __pyx_k__concatenate, sizeof(__pyx_k__concatenate), 0, 0, 1, 1}, {&__pyx_n_s__core, __pyx_k__core, sizeof(__pyx_k__core), 0, 0, 1, 1}, {&__pyx_n_s__count_data, __pyx_k__count_data, sizeof(__pyx_k__count_data), 0, 0, 1, 1}, {&__pyx_n_s__cutoff, __pyx_k__cutoff, sizeof(__pyx_k__cutoff), 0, 0, 1, 1}, {&__pyx_n_s__dat, __pyx_k__dat, sizeof(__pyx_k__dat), 0, 0, 1, 1}, {&__pyx_n_s__delta_AICc, __pyx_k__delta_AICc, sizeof(__pyx_k__delta_AICc), 0, 0, 1, 1}, {&__pyx_n_s__dist, __pyx_k__dist, sizeof(__pyx_k__dist), 0, 0, 1, 1}, {&__pyx_n_s__e_var, __pyx_k__e_var, sizeof(__pyx_k__e_var), 0, 0, 1, 1}, {&__pyx_n_s__ed, __pyx_k__ed, sizeof(__pyx_k__ed), 0, 0, 1, 1}, {&__pyx_n_s__edgecolors, __pyx_k__edgecolors, sizeof(__pyx_k__edgecolors), 0, 0, 1, 1}, {&__pyx_n_s__emp_cdf, __pyx_k__emp_cdf, sizeof(__pyx_k__emp_cdf), 0, 0, 1, 1}, {&__pyx_n_s__empty, __pyx_k__empty, sizeof(__pyx_k__empty), 0, 0, 1, 1}, {&__pyx_n_s__exp, __pyx_k__exp, sizeof(__pyx_k__exp), 0, 0, 1, 1}, {&__pyx_n_s__exp2, __pyx_k__exp2, sizeof(__pyx_k__exp2), 0, 0, 1, 1}, {&__pyx_n_s__fout, __pyx_k__fout, sizeof(__pyx_k__fout), 0, 0, 1, 1}, {&__pyx_n_s__get_emp_cdf, __pyx_k__get_emp_cdf, sizeof(__pyx_k__get_emp_cdf), 0, 0, 1, 1}, {&__pyx_n_s__get_pred_iterative, __pyx_k__get_pred_iterative, sizeof(__pyx_k__get_pred_iterative), 0, 0, 1, 1}, {&__pyx_n_s__get_rad_data, __pyx_k__get_rad_data, sizeof(__pyx_k__get_rad_data), 0, 0, 1, 1}, {&__pyx_n_s__get_rad_from_cdf, __pyx_k__get_rad_from_cdf, sizeof(__pyx_k__get_rad_from_cdf), 0, 0, 1, 1}, {&__pyx_n_s__group_cols, __pyx_k__group_cols, sizeof(__pyx_k__group_cols), 0, 0, 1, 1}, {&__pyx_n_s__groupby, __pyx_k__groupby, sizeof(__pyx_k__groupby), 0, 0, 1, 1}, {&__pyx_n_s__hist, __pyx_k__hist, sizeof(__pyx_k__hist), 0, 0, 1, 1}, {&__pyx_n_s__hist_ab, __pyx_k__hist_ab, sizeof(__pyx_k__hist_ab), 0, 0, 1, 1}, {&__pyx_n_s__hist_ab_norm, __pyx_k__hist_ab_norm, sizeof(__pyx_k__hist_ab_norm), 0, 0, 1, 1}, {&__pyx_n_s__hist_ab_norm1, __pyx_k__hist_ab_norm1, sizeof(__pyx_k__hist_ab_norm1), 0, 0, 1, 1}, {&__pyx_n_s__hist_ab_norm2, __pyx_k__hist_ab_norm2, sizeof(__pyx_k__hist_ab_norm2), 0, 0, 1, 1}, {&__pyx_n_s__hist_pmf, __pyx_k__hist_pmf, sizeof(__pyx_k__hist_pmf), 0, 0, 1, 1}, {&__pyx_n_s__histogram, __pyx_k__histogram, sizeof(__pyx_k__histogram), 0, 0, 1, 1}, {&__pyx_n_s__hold, __pyx_k__hold, sizeof(__pyx_k__hold), 0, 0, 1, 1}, {&__pyx_n_s__hsv_to_rgb, __pyx_k__hsv_to_rgb, sizeof(__pyx_k__hsv_to_rgb), 0, 0, 1, 1}, {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1}, {&__pyx_n_s__identifier, __pyx_k__identifier, sizeof(__pyx_k__identifier), 0, 0, 1, 1}, {&__pyx_n_s__ifile, __pyx_k__ifile, sizeof(__pyx_k__ifile), 0, 0, 1, 1}, {&__pyx_n_s__input_type, __pyx_k__input_type, sizeof(__pyx_k__input_type), 0, 0, 1, 1}, {&__pyx_n_s__intersect12, __pyx_k__intersect12, sizeof(__pyx_k__intersect12), 0, 0, 1, 1}, {&__pyx_n_s__intersection, __pyx_k__intersection, sizeof(__pyx_k__intersection), 0, 0, 1, 1}, {&__pyx_n_s__j, __pyx_k__j, sizeof(__pyx_k__j), 0, 0, 1, 1}, {&__pyx_n_s__k, __pyx_k__k, sizeof(__pyx_k__k), 0, 0, 1, 1}, {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1}, {&__pyx_n_s__list_of_A_and_S, __pyx_k__list_of_A_and_S, sizeof(__pyx_k__list_of_A_and_S), 0, 0, 1, 1}, {&__pyx_n_s__ln_ni_minus_above, __pyx_k__ln_ni_minus_above, sizeof(__pyx_k__ln_ni_minus_above), 0, 0, 1, 1}, {&__pyx_n_s__ln_nj_over_S, __pyx_k__ln_nj_over_S, sizeof(__pyx_k__ln_nj_over_S), 0, 0, 1, 1}, {&__pyx_n_s__log, __pyx_k__log, sizeof(__pyx_k__log), 0, 0, 1, 1}, {&__pyx_n_s__log10, __pyx_k__log10, sizeof(__pyx_k__log10), 0, 0, 1, 1}, {&__pyx_n_s__loglog, __pyx_k__loglog, sizeof(__pyx_k__loglog), 0, 0, 1, 1}, {&__pyx_n_s__logscale, __pyx_k__logscale, sizeof(__pyx_k__logscale), 0, 0, 1, 1}, {&__pyx_n_s__lower_edge_index, __pyx_k__lower_edge_index, sizeof(__pyx_k__lower_edge_index), 0, 0, 1, 1}, {&__pyx_n_s__macroecotools, __pyx_k__macroecotools, sizeof(__pyx_k__macroecotools), 0, 0, 1, 1}, {&__pyx_n_s__map, __pyx_k__map, sizeof(__pyx_k__map), 0, 0, 1, 1}, {&__pyx_n_s__max, __pyx_k__max, sizeof(__pyx_k__max), 0, 0, 1, 1}, {&__pyx_n_s__mean, __pyx_k__mean, sizeof(__pyx_k__mean), 0, 0, 1, 1}, {&__pyx_n_s__min, __pyx_k__min, sizeof(__pyx_k__min), 0, 0, 1, 1}, {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1}, {&__pyx_n_s__ndarray, __pyx_k__ndarray, sizeof(__pyx_k__ndarray), 0, 0, 1, 1}, {&__pyx_n_s__no, __pyx_k__no, sizeof(__pyx_k__no), 0, 0, 1, 1}, {&__pyx_n_s__none, __pyx_k__none, sizeof(__pyx_k__none), 0, 0, 1, 1}, {&__pyx_n_s__normalized, __pyx_k__normalized, sizeof(__pyx_k__normalized), 0, 0, 1, 1}, {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1}, {&__pyx_n_s__num_neighbors, __pyx_k__num_neighbors, sizeof(__pyx_k__num_neighbors), 0, 0, 1, 1}, {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1}, {&__pyx_n_s__nunique, __pyx_k__nunique, sizeof(__pyx_k__nunique), 0, 0, 1, 1}, {&__pyx_n_s__obs, __pyx_k__obs, sizeof(__pyx_k__obs), 0, 0, 1, 1}, {&__pyx_n_s__obs_pred_mse, __pyx_k__obs_pred_mse, sizeof(__pyx_k__obs_pred_mse), 0, 0, 1, 1}, {&__pyx_n_s__obs_pred_rsquare, __pyx_k__obs_pred_rsquare, sizeof(__pyx_k__obs_pred_rsquare), 0, 0, 1, 1}, {&__pyx_n_s__pandas, __pyx_k__pandas, sizeof(__pyx_k__pandas), 0, 0, 1, 1}, {&__pyx_n_s__pars, __pyx_k__pars, sizeof(__pyx_k__pars), 0, 0, 1, 1}, {&__pyx_n_s__pi, __pyx_k__pi, sizeof(__pyx_k__pi), 0, 0, 1, 1}, {&__pyx_n_s__plot, __pyx_k__plot, sizeof(__pyx_k__plot), 0, 0, 1, 1}, {&__pyx_n_s__plot_SARs, __pyx_k__plot_SARs, sizeof(__pyx_k__plot_SARs), 0, 0, 1, 1}, {&__pyx_n_s__plot_data, __pyx_k__plot_data, sizeof(__pyx_k__plot_data), 0, 0, 1, 1}, {&__pyx_n_s__plot_obj, __pyx_k__plot_obj, sizeof(__pyx_k__plot_obj), 0, 0, 1, 1}, {&__pyx_n_s__plot_rad, __pyx_k__plot_rad, sizeof(__pyx_k__plot_rad), 0, 0, 1, 1}, {&__pyx_n_s__plt, __pyx_k__plt, sizeof(__pyx_k__plt), 0, 0, 1, 1}, {&__pyx_n_s__pmf, __pyx_k__pmf, sizeof(__pyx_k__pmf), 0, 0, 1, 1}, {&__pyx_n_s__point, __pyx_k__point, sizeof(__pyx_k__point), 0, 0, 1, 1}, {&__pyx_n_s__point_cdf, __pyx_k__point_cdf, sizeof(__pyx_k__point_cdf), 0, 0, 1, 1}, {&__pyx_n_s__ppf, __pyx_k__ppf, sizeof(__pyx_k__ppf), 0, 0, 1, 1}, {&__pyx_n_s__pred, __pyx_k__pred, sizeof(__pyx_k__pred), 0, 0, 1, 1}, {&__pyx_n_s__preston_sad, __pyx_k__preston_sad, sizeof(__pyx_k__preston_sad), 0, 0, 1, 1}, {&__pyx_n_s__q, __pyx_k__q, sizeof(__pyx_k__q), 0, 0, 1, 1}, {&__pyx_n_s__rad, __pyx_k__rad, sizeof(__pyx_k__rad), 0, 0, 1, 1}, {&__pyx_n_s__radius, __pyx_k__radius, sizeof(__pyx_k__radius), 0, 0, 1, 1}, {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1}, {&__pyx_n_s__rank, __pyx_k__rank, sizeof(__pyx_k__rank), 0, 0, 1, 1}, {&__pyx_n_s__raw_data, __pyx_k__raw_data, sizeof(__pyx_k__raw_data), 0, 0, 1, 1}, {&__pyx_n_s__relab1, __pyx_k__relab1, sizeof(__pyx_k__relab1), 0, 0, 1, 1}, {&__pyx_n_s__relab2, __pyx_k__relab2, sizeof(__pyx_k__relab2), 0, 0, 1, 1}, {&__pyx_n_s__relab_sorted, __pyx_k__relab_sorted, sizeof(__pyx_k__relab_sorted), 0, 0, 1, 1}, {&__pyx_n_s__relative_likelihood, __pyx_k__relative_likelihood, sizeof(__pyx_k__relative_likelihood), 0, 0, 1, 1}, {&__pyx_n_s__reset_index, __pyx_k__reset_index, sizeof(__pyx_k__reset_index), 0, 0, 1, 1}, {&__pyx_n_s__results, __pyx_k__results, sizeof(__pyx_k__results), 0, 0, 1, 1}, {&__pyx_n_s__reverse, __pyx_k__reverse, sizeof(__pyx_k__reverse), 0, 0, 1, 1}, {&__pyx_n_s__richness, __pyx_k__richness, sizeof(__pyx_k__richness), 0, 0, 1, 1}, {&__pyx_n_s__richness_in_group, __pyx_k__richness_in_group, sizeof(__pyx_k__richness_in_group), 0, 0, 1, 1}, {&__pyx_n_s__round, __pyx_k__round, sizeof(__pyx_k__round), 0, 0, 1, 1}, {&__pyx_n_s__scatter, __pyx_k__scatter, sizeof(__pyx_k__scatter), 0, 0, 1, 1}, {&__pyx_n_s__series, __pyx_k__series, sizeof(__pyx_k__series), 0, 0, 1, 1}, {&__pyx_n_s__set_xlim, __pyx_k__set_xlim, sizeof(__pyx_k__set_xlim), 0, 0, 1, 1}, {&__pyx_n_s__set_xscale, __pyx_k__set_xscale, sizeof(__pyx_k__set_xscale), 0, 0, 1, 1}, {&__pyx_n_s__set_ylim, __pyx_k__set_ylim, sizeof(__pyx_k__set_ylim), 0, 0, 1, 1}, {&__pyx_n_s__set_yscale, __pyx_k__set_yscale, sizeof(__pyx_k__set_yscale), 0, 0, 1, 1}, {&__pyx_n_s__setdiff12, __pyx_k__setdiff12, sizeof(__pyx_k__setdiff12), 0, 0, 1, 1}, {&__pyx_n_s__setdiff1d, __pyx_k__setdiff1d, sizeof(__pyx_k__setdiff1d), 0, 0, 1, 1}, {&__pyx_n_s__setdiff21, __pyx_k__setdiff21, sizeof(__pyx_k__setdiff21), 0, 0, 1, 1}, {&__pyx_n_s__setmember1d, __pyx_k__setmember1d, sizeof(__pyx_k__setmember1d), 0, 0, 1, 1}, {&__pyx_n_s__single_identifier, __pyx_k__single_identifier, sizeof(__pyx_k__single_identifier), 0, 0, 1, 1}, {&__pyx_n_s__single_spid, __pyx_k__single_spid, sizeof(__pyx_k__single_spid), 0, 0, 1, 1}, {&__pyx_n_s__site, __pyx_k__site, sizeof(__pyx_k__site), 0, 0, 1, 1}, {&__pyx_n_s__size, __pyx_k__size, sizeof(__pyx_k__size), 0, 0, 1, 1}, {&__pyx_n_s__sort, __pyx_k__sort, sizeof(__pyx_k__sort), 0, 0, 1, 1}, {&__pyx_n_s__sorted, __pyx_k__sorted, sizeof(__pyx_k__sorted), 0, 0, 1, 1}, {&__pyx_n_s__sorted_plot_data, __pyx_k__sorted_plot_data, sizeof(__pyx_k__sorted_plot_data), 0, 0, 1, 1}, {&__pyx_n_s__spdata1, __pyx_k__spdata1, sizeof(__pyx_k__spdata1), 0, 0, 1, 1}, {&__pyx_n_s__spdata2, __pyx_k__spdata2, sizeof(__pyx_k__spdata2), 0, 0, 1, 1}, {&__pyx_n_s__species, __pyx_k__species, sizeof(__pyx_k__species), 0, 0, 1, 1}, {&__pyx_n_s__species_identifiers, __pyx_k__species_identifiers, sizeof(__pyx_k__species_identifiers), 0, 0, 1, 1}, {&__pyx_n_s__spid_col, __pyx_k__spid_col, sizeof(__pyx_k__spid_col), 0, 0, 1, 1}, {&__pyx_n_s__spid_cols, __pyx_k__spid_cols, sizeof(__pyx_k__spid_cols), 0, 0, 1, 1}, {&__pyx_n_s__spid_series, __pyx_k__spid_series, sizeof(__pyx_k__spid_series), 0, 0, 1, 1}, {&__pyx_n_s__sqrt, __pyx_k__sqrt, sizeof(__pyx_k__sqrt), 0, 0, 1, 1}, {&__pyx_n_s__sublist, __pyx_k__sublist, sizeof(__pyx_k__sublist), 0, 0, 1, 1}, {&__pyx_n_s__sum, __pyx_k__sum, sizeof(__pyx_k__sum), 0, 0, 1, 1}, {&__pyx_n_s__transpose, __pyx_k__transpose, sizeof(__pyx_k__transpose), 0, 0, 1, 1}, {&__pyx_n_s__unique_points, __pyx_k__unique_points, sizeof(__pyx_k__unique_points), 0, 0, 1, 1}, {&__pyx_n_s__usites, __pyx_k__usites, sizeof(__pyx_k__usites), 0, 0, 1, 1}, {&__pyx_n_s__v1, __pyx_k__v1, sizeof(__pyx_k__v1), 0, 0, 1, 1}, {&__pyx_n_s__v2, __pyx_k__v2, sizeof(__pyx_k__v2), 0, 0, 1, 1}, {&__pyx_n_s__writerows, __pyx_k__writerows, sizeof(__pyx_k__writerows), 0, 0, 1, 1}, {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1}, {&__pyx_n_s__xlabel, __pyx_k__xlabel, sizeof(__pyx_k__xlabel), 0, 0, 1, 1}, {&__pyx_n_s__xs, __pyx_k__xs, sizeof(__pyx_k__xs), 0, 0, 1, 1}, {&__pyx_n_s__xval, __pyx_k__xval, sizeof(__pyx_k__xval), 0, 0, 1, 1}, {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1}, {&__pyx_n_s__yes, __pyx_k__yes, sizeof(__pyx_k__yes), 0, 0, 1, 1}, {&__pyx_n_s__ylabel, __pyx_k__ylabel, sizeof(__pyx_k__ylabel), 0, 0, 1, 1}, {&__pyx_n_s__yval, __pyx_k__yval, sizeof(__pyx_k__yval), 0, 0, 1, 1}, {&__pyx_n_s__zeros, __pyx_k__zeros, sizeof(__pyx_k__zeros), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_min = __Pyx_GetBuiltinName(__pyx_n_s__min); if (!__pyx_builtin_min) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s__sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s__max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s__map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_sorted = __Pyx_GetBuiltinName(__pyx_n_s__sorted); if (!__pyx_builtin_sorted) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "macroecotools.pyx":144 * rank = range(1, len(Ns) + 1) * plt.plot(rank, Ns, 'bo-') * plt.xlabel('Rank') # <<<<<<<<<<<<<< * plt.ylabel('Abundance') * */ __pyx_k_tuple_2 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__Rank)); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_2); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2)); /* "macroecotools.pyx":145 * plt.plot(rank, Ns, 'bo-') * plt.xlabel('Rank') * plt.ylabel('Abundance') # <<<<<<<<<<<<<< * * def get_rad_data(Ns): */ __pyx_k_tuple_3 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__Abundance)); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_3); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3)); /* "macroecotools.pyx":158 * """Plot histogram of species abundances on a log2 scale""" * if b == None: * q = np.exp2(list(range(0, 25))) # <<<<<<<<<<<<<< * b = q [(q <= max(abund_vector)*2)] * */ __pyx_k_tuple_4 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_25); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_4); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4)); /* "macroecotools.pyx":184 * plt.loglog(sublist[0], sublist[1], color = RGB_tuples[i]) * plt.hold(False) * plt.xlabel('Area') # <<<<<<<<<<<<<< * plt.ylabel('Richness') * */ __pyx_k_tuple_6 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__Area)); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_6); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); /* "macroecotools.pyx":185 * plt.hold(False) * plt.xlabel('Area') * plt.ylabel('Richness') # <<<<<<<<<<<<<< * * def count_pts_within_radius(x, y, radius, logscale=0): */ __pyx_k_tuple_7 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__Richness)); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_7); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7)); /* "macroecotools.pyx":234 * * if loglog == 1: * plot_obj.set_xscale('log') # <<<<<<<<<<<<<< * plot_obj.set_yscale('log') * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], */ __pyx_k_tuple_10 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__log)); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_10); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10)); /* "macroecotools.pyx":235 * if loglog == 1: * plot_obj.set_xscale('log') * plot_obj.set_yscale('log') # <<<<<<<<<<<<<< * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], * c = np.sqrt(sorted_plot_data[:, 2]), edgecolors='none') */ __pyx_k_tuple_11 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__log)); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_11); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11)); /* "macroecotools.pyx":236 * plot_obj.set_xscale('log') * plot_obj.set_yscale('log') * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], # <<<<<<<<<<<<<< * c = np.sqrt(sorted_plot_data[:, 2]), edgecolors='none') * plot_obj.set_xlim(min(x) * 0.5, max(x) * 2) */ __pyx_k_slice_12 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_slice_12); __Pyx_GIVEREF(__pyx_k_slice_12); __pyx_k_tuple_13 = PyTuple_Pack(2, __pyx_k_slice_12, __pyx_int_0); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_13); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13)); __pyx_k_slice_14 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_slice_14); __Pyx_GIVEREF(__pyx_k_slice_14); __pyx_k_tuple_15 = PyTuple_Pack(2, __pyx_k_slice_14, __pyx_int_1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_15); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15)); /* "macroecotools.pyx":237 * plot_obj.set_yscale('log') * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], * c = np.sqrt(sorted_plot_data[:, 2]), edgecolors='none') # <<<<<<<<<<<<<< * plot_obj.set_xlim(min(x) * 0.5, max(x) * 2) * plot_obj.set_ylim(min(y) * 0.5, max(y) * 2) */ __pyx_k_slice_16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_slice_16); __Pyx_GIVEREF(__pyx_k_slice_16); __pyx_k_tuple_17 = PyTuple_Pack(2, __pyx_k_slice_16, __pyx_int_2); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_17); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17)); /* "macroecotools.pyx":241 * plot_obj.set_ylim(min(y) * 0.5, max(y) * 2) * else: * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], # <<<<<<<<<<<<<< * c = log10(sorted_plot_data[:, 2]), edgecolors='none') * return plot_obj */ __pyx_k_slice_18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_slice_18); __Pyx_GIVEREF(__pyx_k_slice_18); __pyx_k_tuple_19 = PyTuple_Pack(2, __pyx_k_slice_18, __pyx_int_0); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_19); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); __pyx_k_slice_20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_slice_20); __Pyx_GIVEREF(__pyx_k_slice_20); __pyx_k_tuple_21 = PyTuple_Pack(2, __pyx_k_slice_20, __pyx_int_1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_21); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); /* "macroecotools.pyx":242 * else: * plot_obj.scatter(sorted_plot_data[:, 0], sorted_plot_data[:, 1], * c = log10(sorted_plot_data[:, 2]), edgecolors='none') # <<<<<<<<<<<<<< * return plot_obj * */ __pyx_k_slice_22 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_slice_22); __Pyx_GIVEREF(__pyx_k_slice_22); __pyx_k_tuple_23 = PyTuple_Pack(2, __pyx_k_slice_22, __pyx_int_2); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_23); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23)); /* "macroecotools.pyx":353 * single_identifier = species_identifiers[0] * if len(species_identifiers) > 1: * for identifier in species_identifiers[1:]: # <<<<<<<<<<<<<< * single_identifier += identifier * if input_type == numpy.ndarray: */ __pyx_k_slice_24 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_k_slice_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_slice_24); __Pyx_GIVEREF(__pyx_k_slice_24); /* "macroecotools.pyx":11 * import numpy * * def AIC(k, L): # <<<<<<<<<<<<<< * """Computes the Akaike Information Criterion. * */ __pyx_k_tuple_28 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__k), ((PyObject *)__pyx_n_s__L), ((PyObject *)__pyx_n_s__AIC)); if (unlikely(!__pyx_k_tuple_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_28); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_28)); __pyx_k_codeobj_29 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__AIC, 11, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":23 * * * def AICc(k, L, n): # <<<<<<<<<<<<<< * """Computes the corrected Akaike Information Criterion. * */ __pyx_k_tuple_31 = PyTuple_Pack(4, ((PyObject *)__pyx_n_s__k), ((PyObject *)__pyx_n_s__L), ((PyObject *)__pyx_n_s__n), ((PyObject *)__pyx_n_s__AICc)); if (unlikely(!__pyx_k_tuple_31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_31); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_31)); __pyx_k_codeobj_32 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__AICc, 23, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":35 * return AICc * * def aic_weight(AICc_list, n, cutoff = 4): # <<<<<<<<<<<<<< * """Computes Akaike weight for one model relative to others * */ __pyx_k_tuple_34 = PyTuple_Pack(9, ((PyObject *)__pyx_n_s__AICc_list), ((PyObject *)__pyx_n_s__n), ((PyObject *)__pyx_n_s__cutoff), ((PyObject *)__pyx_n_s__AICc_weights), ((PyObject *)__pyx_n_s__AICc_min), ((PyObject *)__pyx_n_s_33), ((PyObject *)__pyx_n_s__AICc), ((PyObject *)__pyx_n_s__delta_AICc), ((PyObject *)__pyx_n_s__relative_likelihood)); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_34); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34)); __pyx_k_codeobj_35 = (PyObject*)__Pyx_PyCode_New(3, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__aic_weight, 35, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":64 * return(AICc_weights) * * def get_pred_iterative(cdf_obs, dist, *pars): # <<<<<<<<<<<<<< * """Function to get predicted abundances (reverse-sorted) for distributions with no analytical ppf.""" * cdf_obs = np.sort(cdf_obs) */ __pyx_k_tuple_36 = PyTuple_Pack(8, ((PyObject *)__pyx_n_s__cdf_obs), ((PyObject *)__pyx_n_s__dist), ((PyObject *)__pyx_n_s__pars), ((PyObject *)__pyx_n_s__pars), ((PyObject *)__pyx_n_s__abundance), ((PyObject *)__pyx_n_s__j), ((PyObject *)__pyx_n_s__cdf_cum), ((PyObject *)__pyx_n_s__i)); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_36); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36)); __pyx_k_codeobj_37 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__get_pred_iterative, 64, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":81 * i += 1 * * def get_rad_from_cdf(dist, S, *args): # <<<<<<<<<<<<<< * """Return a predicted rank-abundance distribution from a theoretical CDF * */ __pyx_k_tuple_38 = PyTuple_Pack(7, ((PyObject *)__pyx_n_s__dist), ((PyObject *)__pyx_n_s__S), ((PyObject *)__pyx_n_s__args), ((PyObject *)__pyx_n_s__args), ((PyObject *)__pyx_n_s__emp_cdf), ((PyObject *)__pyx_n_s__rad), ((PyObject *)__pyx_n_s__i)); if (unlikely(!__pyx_k_tuple_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_38); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_38)); __pyx_k_codeobj_39 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__get_rad_from_cdf, 81, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":100 * return np.array(rad) * * def get_emp_cdf(dat): # <<<<<<<<<<<<<< * """Compute the empirical cdf given a list or an array""" * dat = np.array(dat) */ __pyx_k_tuple_40 = PyTuple_Pack(4, ((PyObject *)__pyx_n_s__dat), ((PyObject *)__pyx_n_s__emp_cdf), ((PyObject *)__pyx_n_s__point), ((PyObject *)__pyx_n_s__point_cdf)); if (unlikely(!__pyx_k_tuple_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_40); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40)); __pyx_k_codeobj_41 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__get_emp_cdf, 100, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":109 * return np.array(emp_cdf) * * def hist_pmf(xs, pmf, bins): # <<<<<<<<<<<<<< * """Create a histogram based on a probability mass function * */ __pyx_k_tuple_42 = PyTuple_Pack(5, ((PyObject *)__pyx_n_s__xs), ((PyObject *)__pyx_n_s__pmf), ((PyObject *)__pyx_n_s__bins), ((PyObject *)__pyx_n_s__hist), ((PyObject *)__pyx_n_s__lower_edge_index)); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_42); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42)); __pyx_k_codeobj_43 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__hist_pmf, 109, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":139 * return (hist, bins) * * def plot_rad(Ns): # <<<<<<<<<<<<<< * """Plot a rank-abundance distribution based on a vector of abundances""" * Ns.sort(reverse=True) */ __pyx_k_tuple_44 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__Ns), ((PyObject *)__pyx_n_s__rank)); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_44); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44)); __pyx_k_codeobj_45 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__plot_rad, 139, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":147 * plt.ylabel('Abundance') * * def get_rad_data(Ns): # <<<<<<<<<<<<<< * """Provide ranks and relative abundances for a vector of abundances""" * Ns = np.array(Ns) */ __pyx_k_tuple_46 = PyTuple_Pack(4, ((PyObject *)__pyx_n_s__Ns), ((PyObject *)__pyx_n_s__Ns_sorted), ((PyObject *)__pyx_n_s__relab_sorted), ((PyObject *)__pyx_n_s__rank)); if (unlikely(!__pyx_k_tuple_46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_46); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_46)); __pyx_k_codeobj_47 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__get_rad_data, 147, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":155 * return (rank, relab_sorted) * * def preston_sad(abund_vector, b=None, normalized = 'no'): # <<<<<<<<<<<<<< * """Plot histogram of species abundances on a log2 scale""" * if b == None: */ __pyx_k_tuple_48 = PyTuple_Pack(8, ((PyObject *)__pyx_n_s__abund_vector), ((PyObject *)__pyx_n_s__b), ((PyObject *)__pyx_n_s__normalized), ((PyObject *)__pyx_n_s__q), ((PyObject *)__pyx_n_s__hist_ab), ((PyObject *)__pyx_n_s__hist_ab_norm), ((PyObject *)__pyx_n_s__hist_ab_norm1), ((PyObject *)__pyx_n_s__hist_ab_norm2)); if (unlikely(!__pyx_k_tuple_48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_48); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_48)); __pyx_k_codeobj_49 = (PyObject*)__Pyx_PyCode_New(3, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__preston_sad, 155, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":170 * return hist_ab * * def plot_SARs(list_of_A_and_S): # <<<<<<<<<<<<<< * """Plot multiple SARs on a single plot. * */ __pyx_k_tuple_50 = PyTuple_Pack(7, ((PyObject *)__pyx_n_s__list_of_A_and_S), ((PyObject *)__pyx_n_s__N), ((PyObject *)__pyx_n_s__HSV_tuples), ((PyObject *)__pyx_n_s__RGB_tuples), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__sublist), ((PyObject *)__pyx_n_s__x)); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_50); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50)); __pyx_k_codeobj_51 = (PyObject*)__Pyx_PyCode_New(1, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_50, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__plot_SARs, 170, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":187 * plt.ylabel('Richness') * * def count_pts_within_radius(x, y, radius, logscale=0): # <<<<<<<<<<<<<< * """Count the number of points within a fixed radius in 2D space""" * #TODO: see if we can improve performance using KDTree.query_ball_point */ __pyx_k_tuple_52 = PyTuple_Pack(12, ((PyObject *)__pyx_n_s__x), ((PyObject *)__pyx_n_s__y), ((PyObject *)__pyx_n_s__radius), ((PyObject *)__pyx_n_s__logscale), ((PyObject *)__pyx_n_s__raw_data), ((PyObject *)__pyx_n_s__unique_points), ((PyObject *)__pyx_n_s__xval), ((PyObject *)__pyx_n_s__yval), ((PyObject *)__pyx_n_s__count_data), ((PyObject *)__pyx_n_s__a), ((PyObject *)__pyx_n_s__b), ((PyObject *)__pyx_n_s__num_neighbors)); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_52); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52)); __pyx_k_codeobj_53 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s_8, 187, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":212 * return count_data * * def plot_color_by_pt_dens(x, y, radius, loglog=0, plot_obj=None): # <<<<<<<<<<<<<< * """Plot bivariate relationships with large n using color for point density * */ __pyx_k_tuple_54 = PyTuple_Pack(7, ((PyObject *)__pyx_n_s__x), ((PyObject *)__pyx_n_s__y), ((PyObject *)__pyx_n_s__radius), ((PyObject *)__pyx_n_s__loglog), ((PyObject *)__pyx_n_s__plot_obj), ((PyObject *)__pyx_n_s__plot_data), ((PyObject *)__pyx_n_s__sorted_plot_data)); if (unlikely(!__pyx_k_tuple_54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_54); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_54)); __pyx_k_codeobj_55 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s_56, 212, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":245 * return plot_obj * * def e_var(abundance_data): # <<<<<<<<<<<<<< * """Calculate Smith and Wilson's (1996; Oikos 76:70-82) evenness index (Evar) * */ __pyx_k_tuple_57 = PyTuple_Pack(7, ((PyObject *)__pyx_n_s__abundance_data), ((PyObject *)__pyx_n_s__S), ((PyObject *)__pyx_n_s__ln_nj_over_S), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__v1), ((PyObject *)__pyx_n_s__ln_ni_minus_above), ((PyObject *)__pyx_n_s__v2)); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_57); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57)); __pyx_k_codeobj_58 = (PyObject*)__Pyx_PyCode_New(1, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__e_var, 245, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":265 * return(1 - ((2 / np.pi) * np.arctan(sum(ln_ni_minus_above) / S))) * * def obs_pred_rsquare(obs, pred): # <<<<<<<<<<<<<< * """Determines the prop of variability in a data set accounted for by a model * */ __pyx_k_tuple_59 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__obs), ((PyObject *)__pyx_n_s__pred)); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_59); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59)); __pyx_k_codeobj_60 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__obs_pred_rsquare, 265, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":274 * return 1 - sum((obs - pred) ** 2) / sum((obs - np.mean(obs)) ** 2) * * def obs_pred_mse(obs, pred): # <<<<<<<<<<<<<< * """Calculate the mean squared error of the prediction given observation.""" * */ __pyx_k_tuple_61 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__obs), ((PyObject *)__pyx_n_s__pred)); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_61); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61)); __pyx_k_codeobj_62 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__obs_pred_mse, 274, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":279 * return sum((obs - pred) ** 2) / len(obs) * * def comp_ed (spdata1,abdata1,spdata2,abdata2): # <<<<<<<<<<<<<< * """Calculate the compositional Euclidean Distance between two sites * */ __pyx_k_tuple_63 = PyTuple_Pack(9, ((PyObject *)__pyx_n_s__spdata1), ((PyObject *)__pyx_n_s__abdata1), ((PyObject *)__pyx_n_s__spdata2), ((PyObject *)__pyx_n_s__abdata2), ((PyObject *)__pyx_n_s__intersect12), ((PyObject *)__pyx_n_s__setdiff12), ((PyObject *)__pyx_n_s__setdiff21), ((PyObject *)__pyx_n_s__relab1), ((PyObject *)__pyx_n_s__relab2)); if (unlikely(!__pyx_k_tuple_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_63); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_63)); __pyx_k_codeobj_64 = (PyObject*)__Pyx_PyCode_New(4, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__comp_ed, 279, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":299 * return np.sqrt(sum((relab1 - relab2) ** 2)) * * def calc_comp_eds(ifile, fout, cutoff=4): # <<<<<<<<<<<<<< * """Calculate Euclidean distances in species composition across sites. * */ __pyx_k_tuple_65 = PyTuple_Pack(12, ((PyObject *)__pyx_n_s__ifile), ((PyObject *)__pyx_n_s__fout), ((PyObject *)__pyx_n_s__cutoff), ((PyObject *)__pyx_n_s__usites), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__spdata1), ((PyObject *)__pyx_n_s__abdata1), ((PyObject *)__pyx_n_s__a), ((PyObject *)__pyx_n_s__spdata2), ((PyObject *)__pyx_n_s__abdata2), ((PyObject *)__pyx_n_s__ed), ((PyObject *)__pyx_n_s__results)); if (unlikely(!__pyx_k_tuple_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_65); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_65)); __pyx_k_codeobj_66 = (PyObject*)__Pyx_PyCode_New(3, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__calc_comp_eds, 299, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":330 * fout.writerows(results) * * def combined_spID(*species_identifiers): # <<<<<<<<<<<<<< * """Return a single column unique species identifier * */ __pyx_k_tuple_67 = PyTuple_Pack(5, ((PyObject *)__pyx_n_s__species_identifiers), ((PyObject *)__pyx_n_s__species_identifiers), ((PyObject *)__pyx_n_s__input_type), ((PyObject *)__pyx_n_s__single_identifier), ((PyObject *)__pyx_n_s__identifier)); if (unlikely(!__pyx_k_tuple_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_67); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_67)); __pyx_k_codeobj_68 = (PyObject*)__Pyx_PyCode_New(0, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__combined_spID, 330, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":361 * return single_identifier * * def richness_in_group(composition_data, group_cols, spid_cols): # <<<<<<<<<<<<<< * """Determine the number of species in a grouping (e.g., at each site) * */ __pyx_k_tuple_69 = PyTuple_Pack(7, ((PyObject *)__pyx_n_s__composition_data), ((PyObject *)__pyx_n_s__group_cols), ((PyObject *)__pyx_n_s__spid_cols), ((PyObject *)__pyx_n_s__spid_series), ((PyObject *)__pyx_n_s__single_spid), ((PyObject *)__pyx_n_s__richness), ((PyObject *)__pyx_n_s__spid_col)); if (unlikely(!__pyx_k_tuple_69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_69); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_69)); __pyx_k_codeobj_70 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__richness_in_group, 361, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "macroecotools.pyx":396 * return richness * * def abundance_in_group(composition_data, group_cols, abund_col=None): # <<<<<<<<<<<<<< * """Determine the number of individuals in a grouping (e.g., at each site) * */ __pyx_k_tuple_71 = PyTuple_Pack(4, ((PyObject *)__pyx_n_s__composition_data), ((PyObject *)__pyx_n_s__group_cols), ((PyObject *)__pyx_n_s__abund_col), ((PyObject *)__pyx_n_s__abundance)); if (unlikely(!__pyx_k_tuple_71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_71); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_71)); __pyx_k_codeobj_72 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__abundance_in_group, 396, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_25 = PyInt_FromLong(25); if (unlikely(!__pyx_int_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; return 0; __pyx_L1_error:; return -1; } #if PY_MAJOR_VERSION < 3 PyMODINIT_FUNC initmacroecotools(void); /*proto*/ PyMODINIT_FUNC initmacroecotools(void) #else PyMODINIT_FUNC PyInit_macroecotools(void); /*proto*/ PyMODINIT_FUNC PyInit_macroecotools(void) #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #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("PyMODINIT_FUNC PyInit_macroecotools(void)", 0); if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #ifdef __Pyx_CyFunction_USED if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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 PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4(__Pyx_NAMESTR("macroecotools"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_25), 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!PyDict_GetItemString(modules, "macroecotools")) { if (unlikely(PyDict_SetItemString(modules, "macroecotools", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; /*--- Initialize various global constants etc. ---*/ if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_macroecotools) { if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; } /*--- Builtin init code ---*/ if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ /*--- Type import code ---*/ /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ /* "macroecotools.pyx":4 * * from __future__ import division * import numpy as np # <<<<<<<<<<<<<< * import matplotlib.pyplot as plt * import colorsys */ __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":5 * from __future__ import division * import numpy as np * import matplotlib.pyplot as plt # <<<<<<<<<<<<<< * import colorsys * from numpy import log10 */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_n_s_27)); PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s_27)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s_27)); __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_26), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s__plt, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":6 * import numpy as np * import matplotlib.pyplot as plt * import colorsys # <<<<<<<<<<<<<< * from numpy import log10 * import pandas */ __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__colorsys), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s__colorsys, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "macroecotools.pyx":7 * import matplotlib.pyplot as plt * import colorsys * from numpy import log10 # <<<<<<<<<<<<<< * import pandas * import numpy */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_n_s__log10)); PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__log10)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__log10)); __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s__log10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s__log10, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":8 * import colorsys * from numpy import log10 * import pandas # <<<<<<<<<<<<<< * import numpy * */ __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__pandas), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__pandas, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":9 * from numpy import log10 * import pandas * import numpy # <<<<<<<<<<<<<< * * def AIC(k, L): */ __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__numpy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":11 * import numpy * * def AIC(k, L): # <<<<<<<<<<<<<< * """Computes the Akaike Information Criterion. * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_1AIC, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__AIC, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":23 * * * def AICc(k, L, n): # <<<<<<<<<<<<<< * """Computes the corrected Akaike Information Criterion. * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_3AICc, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__AICc, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":35 * return AICc * * def aic_weight(AICc_list, n, cutoff = 4): # <<<<<<<<<<<<<< * """Computes Akaike weight for one model relative to others * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_5aic_weight, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__aic_weight, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":64 * return(AICc_weights) * * def get_pred_iterative(cdf_obs, dist, *pars): # <<<<<<<<<<<<<< * """Function to get predicted abundances (reverse-sorted) for distributions with no analytical ppf.""" * cdf_obs = np.sort(cdf_obs) */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_7get_pred_iterative, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__get_pred_iterative, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":81 * i += 1 * * def get_rad_from_cdf(dist, S, *args): # <<<<<<<<<<<<<< * """Return a predicted rank-abundance distribution from a theoretical CDF * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_9get_rad_from_cdf, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__get_rad_from_cdf, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":100 * return np.array(rad) * * def get_emp_cdf(dat): # <<<<<<<<<<<<<< * """Compute the empirical cdf given a list or an array""" * dat = np.array(dat) */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_11get_emp_cdf, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__get_emp_cdf, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":109 * return np.array(emp_cdf) * * def hist_pmf(xs, pmf, bins): # <<<<<<<<<<<<<< * """Create a histogram based on a probability mass function * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_13hist_pmf, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__hist_pmf, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":139 * return (hist, bins) * * def plot_rad(Ns): # <<<<<<<<<<<<<< * """Plot a rank-abundance distribution based on a vector of abundances""" * Ns.sort(reverse=True) */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_15plot_rad, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__plot_rad, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":147 * plt.ylabel('Abundance') * * def get_rad_data(Ns): # <<<<<<<<<<<<<< * """Provide ranks and relative abundances for a vector of abundances""" * Ns = np.array(Ns) */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_17get_rad_data, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__get_rad_data, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":155 * return (rank, relab_sorted) * * def preston_sad(abund_vector, b=None, normalized = 'no'): # <<<<<<<<<<<<<< * """Plot histogram of species abundances on a log2 scale""" * if b == None: */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_19preston_sad, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__preston_sad, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":170 * return hist_ab * * def plot_SARs(list_of_A_and_S): # <<<<<<<<<<<<<< * """Plot multiple SARs on a single plot. * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_21plot_SARs, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__plot_SARs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":187 * plt.ylabel('Richness') * * def count_pts_within_radius(x, y, radius, logscale=0): # <<<<<<<<<<<<<< * """Count the number of points within a fixed radius in 2D space""" * #TODO: see if we can improve performance using KDTree.query_ball_point */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_23count_pts_within_radius, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_8, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":212 * return count_data * * def plot_color_by_pt_dens(x, y, radius, loglog=0, plot_obj=None): # <<<<<<<<<<<<<< * """Plot bivariate relationships with large n using color for point density * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_25plot_color_by_pt_dens, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_56, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":245 * return plot_obj * * def e_var(abundance_data): # <<<<<<<<<<<<<< * """Calculate Smith and Wilson's (1996; Oikos 76:70-82) evenness index (Evar) * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_27e_var, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__e_var, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":265 * return(1 - ((2 / np.pi) * np.arctan(sum(ln_ni_minus_above) / S))) * * def obs_pred_rsquare(obs, pred): # <<<<<<<<<<<<<< * """Determines the prop of variability in a data set accounted for by a model * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_29obs_pred_rsquare, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__obs_pred_rsquare, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":274 * return 1 - sum((obs - pred) ** 2) / sum((obs - np.mean(obs)) ** 2) * * def obs_pred_mse(obs, pred): # <<<<<<<<<<<<<< * """Calculate the mean squared error of the prediction given observation.""" * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_31obs_pred_mse, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__obs_pred_mse, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":279 * return sum((obs - pred) ** 2) / len(obs) * * def comp_ed (spdata1,abdata1,spdata2,abdata2): # <<<<<<<<<<<<<< * """Calculate the compositional Euclidean Distance between two sites * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_33comp_ed, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__comp_ed, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":299 * return np.sqrt(sum((relab1 - relab2) ** 2)) * * def calc_comp_eds(ifile, fout, cutoff=4): # <<<<<<<<<<<<<< * """Calculate Euclidean distances in species composition across sites. * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_35calc_comp_eds, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__calc_comp_eds, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":330 * fout.writerows(results) * * def combined_spID(*species_identifiers): # <<<<<<<<<<<<<< * """Return a single column unique species identifier * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_37combined_spID, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__combined_spID, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":361 * return single_identifier * * def richness_in_group(composition_data, group_cols, spid_cols): # <<<<<<<<<<<<<< * """Determine the number of species in a grouping (e.g., at each site) * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_39richness_in_group, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__richness_in_group, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":396 * return richness * * def abundance_in_group(composition_data, group_cols, abund_col=None): # <<<<<<<<<<<<<< * """Determine the number of individuals in a grouping (e.g., at each site) * */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_13macroecotools_41abundance_in_group, NULL, __pyx_n_s__macroecotools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s__abundance_in_group, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macroecotools.pyx":1 * """Module for conducting standard macroecological plots and analyses""" # <<<<<<<<<<<<<< * * from __future__ import division */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { __Pyx_AddTraceback("init macroecotools", __pyx_clineno, __pyx_lineno, __pyx_filename); Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init macroecotools"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if PY_MAJOR_VERSION < 3 return; #else return __pyx_m; #endif } /* Runtime support code */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* CYTHON_REFNANNY */ 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 '%s' is not defined", PyString_AS_STRING(name)); #endif } return result; } 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, "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } 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 } 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_CheckExact(key)) || 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 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(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 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(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, "%s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%s() got an unexpected keyword argument '%s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); if (result) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) { if (likely(PyList_CheckExact(L))) { if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return NULL; Py_INCREF(Py_None); return Py_None; /* this is just to have an accurate signature */ } else { return __Pyx_PyObject_CallMethod1(L, __pyx_n_s__append, x); } } static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { PyObject *local_type, *local_value, *local_tb; #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); 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_COMPILING_IN_CPYTHON if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; #endif Py_INCREF(local_type); Py_INCREF(local_value); Py_INCREF(local_tb); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_COMPILING_IN_CPYTHON 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; /* Make sure tstate is in a consistent state when we XDECREF these objects (DECREF may run arbitrary code). */ 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; } static CYTHON_INLINE 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, int wraparound, int boundscheck) { #if CYTHON_COMPILING_IN_CPYTHON if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, 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, int wraparound, int boundscheck) { #if CYTHON_COMPILING_IN_CPYTHON if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, 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, int wraparound, int boundscheck) { #if CYTHON_COMPILING_IN_CPYTHON if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely((n >= 0) & (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((n >= 0) & (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)) PyErr_Clear(); else return NULL; } } 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)); } 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_COMPILING_IN_CPYTHON 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)) PyErr_Clear(); else goto bad; } } 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_COMPILING_IN_CPYTHON 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; } static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } 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) { PyObject *tmp = op->func_doc; if (value == NULL) value = Py_None; /* Mark as deleted */ Py_INCREF(value); op->func_doc = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op) { 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) { 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) { Py_INCREF(op->func_qualname); return op->func_qualname; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value) { 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) { 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) { 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(CYTHON_UNUSED __pyx_CyFunctionObject *op) { PyObject* dict = PyModule_GetDict(__pyx_m); Py_XINCREF(dict); return dict; } static PyObject * __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op) { Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op) { PyObject* result = (op->func_code) ? op->func_code : Py_None; Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; 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); Py_DECREF(res); return 0; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) { 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) { 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) { 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) { 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) { 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) { 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} }; #ifndef PY_WRITE_RESTRICTED /* < Py2.5 */ #define PY_WRITE_RESTRICTED WRITE_RESTRICTED #endif static PyMemberDef __pyx_CyFunction_members[] = { {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.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 return PyUnicode_FromString(m->func.m_ml->ml_name); #else return PyString_FromString(m->func.m_ml->ml_name); #endif } static PyMethodDef __pyx_CyFunction_methods[] = { {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* code) { __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); if (op == NULL) return NULL; op->flags = flags; op->func_weakreflist = 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; Py_XINCREF(code); op->func_code = code; op->defaults_pyobjects = 0; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; PyObject_GC_Track(op); 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_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]); PyMem_Free(m->defaults); m->defaults = NULL; } return 0; } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); if (m->func_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); PyObject_GC_Del(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_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) { __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 PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); } if (obj == Py_None) obj = NULL; return PyMethod_New(func, obj, type); } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromFormat("<cyfunction %U at %p>", op->func_qualname, (void *)op); #else return PyString_FromFormat("<cyfunction %s at %p>", PyString_AsString(op->func_qualname), (void *)op); #endif } #if CYTHON_COMPILING_IN_PYPY static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); Py_ssize_t size; switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) { case METH_VARARGS: if (likely(kw == NULL) || PyDict_Size(kw) == 0) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL) || PyDict_Size(kw) == 0) { size = PyTuple_GET_SIZE(arg); if (size == 0) return (*meth)(self, NULL); PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%zd 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 (size == 1) return (*meth)(self, PyTuple_GET_ITEM(arg, 0)); PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%zd 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; } #else static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { return PyCFunction_Call(func, arg, kw); } #endif static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/ sizeof(__pyx_CyFunctionObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #else 0, /*reserved*/ #endif (reprfunc) __Pyx_CyFunction_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ __Pyx_CyFunction_Call, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/ 0, /*tp_doc*/ (traverseproc) __Pyx_CyFunction_traverse, /*tp_traverse*/ (inquiry) __Pyx_CyFunction_clear, /*tp_clear*/ 0, /*tp_richcompare*/ offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_CyFunction_methods, /*tp_methods*/ __pyx_CyFunction_members, /*tp_members*/ __pyx_CyFunction_getsets, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ __Pyx_CyFunction_descr_get, /*tp_descr_get*/ 0, /*tp_descr_set*/ offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ 0, /*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*/ #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif #if PY_VERSION_HEX >= 0x030400a1 && defined(Py_TPFLAGS_HAVE_FINALIZE) 0, /*tp_finalize*/ #endif }; static int __Pyx_CyFunction_init(void) { #if !CYTHON_COMPILING_IN_PYPY __pyx_CyFunctionType_type.tp_call = PyCFunction_Call; #endif if (PyType_Ready(&__pyx_CyFunctionType_type) < 0) return -1; __pyx_CyFunctionType = &__pyx_CyFunctionType_type; return 0; } static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyMem_Malloc(size); if (!m->defaults) return PyErr_NoMemory(); memset(m->defaults, 0, size); m->defaults_pyobjects = pyobjects; 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); } 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); } static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", index, (index == 1) ? "" : "s"); } static CYTHON_INLINE int __Pyx_IterFinish(void) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); PyObject* exc_type = tstate->curexc_type; if (unlikely(exc_type)) { if (likely(exc_type == PyExc_StopIteration) || 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 } static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } else { return __Pyx_IterFinish(); } return 0; } static CYTHON_INLINE int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) { PyObject* key = 0; Py_ssize_t pos = 0; #if CPYTHON_COMPILING_IN_PYPY if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) goto invalid_keyword; return 1; #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; } if ((!kw_allowed) && unlikely(key)) goto invalid_keyword; return 1; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%s() keywords must be strings", function_name); return 0; #endif invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%s() got an unexpected keyword argument '%s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif return 0; } 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; } static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #else PyErr_GetExcInfo(type, value, tb); #endif } static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); 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; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(type, value, tb); #endif } 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_VERSION_HEX < 0x03030000 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_VERSION_HEX >= 0x02050000 { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(1); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; /* try absolute import on failure */ } #endif if (!module) { #if PY_VERSION_HEX < 0x03030000 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } #else if (level>0) { PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); goto bad; } module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, NULL); #endif bad: #if PY_VERSION_HEX < 0x03030000 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { const unsigned char neg_one = (unsigned char)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(unsigned char) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(unsigned char)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to unsigned char" : "value too large to convert to unsigned char"); } return (unsigned char)-1; } return (unsigned char)val; } return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); } static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { const unsigned short neg_one = (unsigned short)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(unsigned short) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(unsigned short)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to unsigned short" : "value too large to convert to unsigned short"); } return (unsigned short)-1; } return (unsigned short)val; } return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); } static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { const unsigned int neg_one = (unsigned int)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(unsigned int) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(unsigned int)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to unsigned int" : "value too large to convert to unsigned int"); } return (unsigned int)-1; } return (unsigned int)val; } return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); } static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { const char neg_one = (char)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(char) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(char)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to char" : "value too large to convert to char"); } return (char)-1; } return (char)val; } return (char)__Pyx_PyInt_AsLong(x); } static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { const short neg_one = (short)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(short) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(short)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to short" : "value too large to convert to short"); } return (short)-1; } return (short)val; } return (short)__Pyx_PyInt_AsLong(x); } static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { const int neg_one = (int)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(int) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(int)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to int" : "value too large to convert to int"); } return (int)-1; } return (int)val; } return (int)__Pyx_PyInt_AsLong(x); } static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { const signed char neg_one = (signed char)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(signed char) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(signed char)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to signed char" : "value too large to convert to signed char"); } return (signed char)-1; } return (signed char)val; } return (signed char)__Pyx_PyInt_AsSignedLong(x); } static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { const signed short neg_one = (signed short)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(signed short) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(signed short)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to signed short" : "value too large to convert to signed short"); } return (signed short)-1; } return (signed short)val; } return (signed short)__Pyx_PyInt_AsSignedLong(x); } static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { const signed int neg_one = (signed int)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(signed int) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(signed int)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to signed int" : "value too large to convert to signed int"); } return (signed int)-1; } return (signed int)val; } return (signed int)__Pyx_PyInt_AsSignedLong(x); } static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { const int neg_one = (int)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; if (sizeof(int) < sizeof(long)) { long val = __Pyx_PyInt_AsLong(x); if (unlikely(val != (long)(int)val)) { if (!unlikely(val == -1 && PyErr_Occurred())) { PyErr_SetString(PyExc_OverflowError, (is_unsigned && unlikely(val < 0)) ? "can't convert negative value to int" : "value too large to convert to int"); } return (int)-1; } return (int)val; } return (int)__Pyx_PyInt_AsLong(x); } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif #endif static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { const unsigned long neg_one = (unsigned long)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned long"); return (unsigned long)-1; } return (unsigned long)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(unsigned long)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned long"); return (unsigned long)-1; } return (unsigned long)PyLong_AsUnsignedLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(unsigned long)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif return (unsigned long)PyLong_AsLong(x); } } else { unsigned long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (unsigned long)-1; val = __Pyx_PyInt_AsUnsignedLong(tmp); Py_DECREF(tmp); return val; } } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif #endif static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG)-1; } return (unsigned PY_LONG_LONG)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG)-1; } return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); } } else { unsigned PY_LONG_LONG val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (unsigned PY_LONG_LONG)-1; val = __Pyx_PyInt_AsUnsignedLongLong(tmp); Py_DECREF(tmp); return val; } } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif #endif static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { const long neg_one = (long)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long)-1; } return (long)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(long)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long)-1; } return (long)PyLong_AsUnsignedLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(long)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif return (long)PyLong_AsLong(x); } } else { long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (long)-1; val = __Pyx_PyInt_AsLong(tmp); Py_DECREF(tmp); return val; } } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif #endif static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to PY_LONG_LONG"); return (PY_LONG_LONG)-1; } return (PY_LONG_LONG)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to PY_LONG_LONG"); return (PY_LONG_LONG)-1; } return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif return (PY_LONG_LONG)PyLong_AsLongLong(x); } } else { PY_LONG_LONG val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1; val = __Pyx_PyInt_AsLongLong(tmp); Py_DECREF(tmp); return val; } } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif #endif static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { const signed long neg_one = (signed long)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to signed long"); return (signed long)-1; } return (signed long)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(signed long)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to signed long"); return (signed long)-1; } return (signed long)PyLong_AsUnsignedLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(signed long)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif return (signed long)PyLong_AsLong(x); } } else { signed long val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (signed long)-1; val = __Pyx_PyInt_AsSignedLong(tmp); Py_DECREF(tmp); return val; } } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #endif #endif static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to signed PY_LONG_LONG"); return (signed PY_LONG_LONG)-1; } return (signed PY_LONG_LONG)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to signed PY_LONG_LONG"); return (signed PY_LONG_LONG)-1; } return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; } } #endif #endif return (signed PY_LONG_LONG)PyLong_AsLongLong(x); } } else { signed PY_LONG_LONG val; PyObject *tmp = __Pyx_PyNumber_Int(x); if (!tmp) return (signed PY_LONG_LONG)-1; val = __Pyx_PyInt_AsSignedLongLong(tmp); Py_DECREF(tmp); return val; } } 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); #if PY_VERSION_HEX < 0x02050000 return PyErr_Warn(NULL, message); #else return PyErr_WarnEx(NULL, message, 1); #endif } return 0; } 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) / 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, 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); } #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, /*int argcount,*/ 0, /*int kwonlyargcount,*/ 0, /*int nlocals,*/ 0, /*int stacksize,*/ 0, /*int flags,*/ __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, /*int firstlineno,*/ __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; PyObject *py_globals = 0; PyFrameObject *py_frame = 0; 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_globals = PyModule_GetDict(__pyx_m); if (!py_globals) goto bad; py_frame = PyFrame_New( PyThreadState_GET(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ py_globals, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = py_line; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } 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 /* Python 3+ has unicode identifiers */ 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; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str)); } static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE 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)) { #if PY_VERSION_HEX < 0x03030000 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 /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/ *length = PyBytes_GET_SIZE(defenc); return defenc_c; #else /* PY_VERSION_HEX < 0x03030000 */ if (PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_DATA_SIZE(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ return PyUnicode_AsUTF8AndSize(o, length); #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ #endif /* PY_VERSION_HEX < 0x03030000 */ } else #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (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 PyObject* __Pyx_PyNumber_Int(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (PyInt_Check(x) || PyLong_Check(x)) #else if (PyLong_Check(x)) #endif return Py_INCREF(x), x; m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = PyNumber_Int(x); } else if (m && m->nb_long) { name = "long"; res = PyNumber_Long(x); } #else if (m && m->nb_int) { name = "int"; res = PyNumber_Long(x); } #endif if (res) { #if PY_MAJOR_VERSION < 3 if (!PyInt_Check(res) && !PyLong_Check(res)) { #else if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, "__%s__ returned non-%s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } } 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 = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { #if PY_VERSION_HEX < 0x02050000 if (ival <= LONG_MAX) return PyInt_FromLong((long)ival); else { unsigned char *bytes = (unsigned char *) &ival; int one = 1; int little = (int)*(unsigned char*)&one; return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); } #else return PyInt_FromSize_t(ival); #endif } static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) PyErr_SetString(PyExc_OverflowError, "value too large to convert to size_t"); return (size_t)-1; } return (size_t)val; } #endif /* Py_PYTHON_H */
50.771306
1,409
0.699603
daf8db899d57b48b2a9b8952458df490cab5b555
4,307
h
C
demo-swift/Quickblox.framework/Versions/A/Headers/QBRequest+QBAuth.h
bluecitymoon/demo-swift-ios
bfd551d32c4e332cc8116aae92ae72ecd80bf4a7
[ "MIT" ]
1
2017-02-21T21:08:04.000Z
2017-02-21T21:08:04.000Z
demo-swift/Quickblox.framework/Versions/A/Headers/QBRequest+QBAuth.h
bluecitymoon/demo-swift-ios
bfd551d32c4e332cc8116aae92ae72ecd80bf4a7
[ "MIT" ]
null
null
null
demo-swift/Quickblox.framework/Versions/A/Headers/QBRequest+QBAuth.h
bluecitymoon/demo-swift-ios
bfd551d32c4e332cc8116aae92ae72ecd80bf4a7
[ "MIT" ]
null
null
null
// // Created by Andrey Kozlov on 14/12/2013. // Copyright (c) 2013 QuickBlox. All rights reserved. // #import <Foundation/Foundation.h> #import "QBRequest.h" @class QBResponse; @class QBASession; @class QBSessionParameters; @class QBUUser; @interface QBRequest (QBAuth) #pragma mark - App authorization /** Session Creation @return An instance of QBRequest for cancel operation mainly. */ + (QBRequest *)createSessionWithSuccessBlock:(void (^)(QBResponse *response, QBASession *session))successBlock errorBlock:(QBRequestErrorBlock)errorBlock; /** Session Creation with extended Request Type of Result - QBAAuthSessionCreationResult. @param extendedParameters Extended set of request parameters @return An instance of QBRequest for cancel operation mainly. */ + (QBRequest *)createSessionWithExtendedParameters:(QBSessionParameters *)extendedParameters successBlock:(void (^)(QBResponse *response, QBASession *session))successBlock errorBlock:(QBRequestErrorBlock)errorBlock; /** Session Destroy Type of Result - QBAAuthResult. @return An instance, which conforms Cancelable protocol. Use this instance to cancel the operation. */ + (QBRequest *)destroySessionWithSuccessBlock:(void (^)(QBResponse *response))successBlock errorBlock:(QBRequestErrorBlock)errorBlock; #pragma mark - LogIn /** * User LogIn with login * * @param login Login of QBUUser which authenticates. * @param password Password of QBUUser which authenticates. * @param successBlock An callback. Will return QBUserSessionInformation class if request is successful. * @return An instance of QBRequest for cancel operation mainly. */ + (QBRequest *)logInWithUserLogin:(NSString *)login password:(NSString *)password successBlock:(void (^)(QBResponse *response, QBUUser *user))successBlock errorBlock:(QBRequestErrorBlock)errorBlock; /** User LogIn with email @param email Email of QBUUser which authenticates. @param password Password of QBUUser which authenticates. @return An instance of QBRequest for cancel operation mainly. */ + (QBRequest *)logInWithUserEmail:(NSString *)email password:(NSString *)password successBlock:(void (^)(QBResponse *response, QBUUser *user))successBlock errorBlock:(QBRequestErrorBlock)errorBlock; /** User LogIn with social provider @param provider Social provider. Posible values: facebook, twitter. @param scope Permission. Permissions for choosen provider. Should not be nil. @return An instance of QBRequest for cancel operation mainly. */ + (QBRequest *)logInWithSocialProvider:(NSString *)provider scope:(NSArray *)scope successBlock:(void (^)(QBResponse *response, QBUUser* user))successBlock errorBlock:(void (^)(QBResponse *response))errorBlock; /** User LogIn with social provider's token @param provider Social provider. Posible values: facebook, twitter. @param accessToken Social provider access token. @param accessTokenSecret Social provider access token secret. @return An instance of QBRequest for cancel operation mainly. */ + (QBRequest *)logInWithSocialProvider:(NSString *)provider accessToken:(NSString *)accessToken accessTokenSecret:(NSString *)accessTokenSecret successBlock:(void (^)(QBResponse *response, QBUUser *user))successBlock errorBlock:(void (^)(QBResponse *response))errorBlock; #pragma mark - LogOut /** User LogOut Type of Result - QBUUserLogOutResult @param successBlock An object for callback, must adopt QBActionStatusDelegate protocol. The delegate is retained. Upon finish of the request, result will be an instance of QBUUserLogoutResult class. @return An instance, which conforms Cancelable protocol. Use this instance to cancel the operation. */ + (QBRequest *)logOutWithSuccessBlock:(void (^)(QBResponse *response))successBlock errorBlock:(QBRequestErrorBlock)errorBlock; #pragma mark - Create User /** User sign up @param successBlock Block with response and users instances if request succeded @param errorBlock Block with response instance if request failed @return An instance of QBRequest. Use this instance to cancel the operation. */ + (QBRequest *)signUp:(QBUUser *)user successBlock:(void (^)(QBResponse *response, QBUUser *user))successBlock errorBlock:(void (^)(QBResponse *response))errorBlock; @end
38.801802
215
0.771303
ddb40e8d1106bd47e6729fdee85e048123c213f5
1,149
h
C
src/strategy/generic/LootNonCombatStrategy.h
htc16/mod-playerbots
2307e3f980035a244bfb4fedefda5bc55903d470
[ "MIT" ]
12
2022-03-23T05:14:53.000Z
2022-03-30T12:12:58.000Z
src/strategy/generic/LootNonCombatStrategy.h
htc16/mod-playerbots
2307e3f980035a244bfb4fedefda5bc55903d470
[ "MIT" ]
24
2022-03-23T13:56:37.000Z
2022-03-31T18:23:32.000Z
src/strategy/generic/LootNonCombatStrategy.h
htc16/mod-playerbots
2307e3f980035a244bfb4fedefda5bc55903d470
[ "MIT" ]
3
2022-03-24T21:47:10.000Z
2022-03-31T06:21:46.000Z
/* * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOOTNONCOMBATSTRATEGY_H #define _PLAYERBOT_LOOTNONCOMBATSTRATEGY_H #include "Strategy.h" class PlayerbotAI; class LootNonCombatStrategy : public Strategy { public: LootNonCombatStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } void InitTriggers(std::vector<TriggerNode*>& triggers) override; std::string const getName() override { return "loot"; } }; class GatherStrategy : public Strategy { public: GatherStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } void InitTriggers(std::vector<TriggerNode*>& triggers) override; std::string const getName() override { return "gather"; } }; class RevealStrategy : public Strategy { public: RevealStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } void InitTriggers(std::vector<TriggerNode*>& triggers) override; std::string const getName() override { return "reveal"; } }; #endif
28.725
205
0.705831
9786a513b9b944ddbf067050d9ed27cde9362045
2,955
h
C
.vim/sourceCode/glibc-2.16.0/sunrpc/rpc_scan.h
lakehui/Vim_config
6cab80dc1209b34bf6379f42b1a92790bd0c146b
[ "MIT" ]
47
2015-03-10T23:21:52.000Z
2022-02-17T01:04:14.000Z
.vim/sourceCode/glibc-2.16.0/sunrpc/rpc_scan.h
lakehui/Vim_config
6cab80dc1209b34bf6379f42b1a92790bd0c146b
[ "MIT" ]
1
2020-06-30T18:01:37.000Z
2020-06-30T18:01:37.000Z
.vim/sourceCode/glibc-2.16.0/sunrpc/rpc_scan.h
lakehui/Vim_config
6cab80dc1209b34bf6379f42b1a92790bd0c146b
[ "MIT" ]
19
2015-02-25T19:50:05.000Z
2021-10-05T14:35:54.000Z
/* @(#)rpc_scan.h 1.3 90/08/29 */ /* * Copyright (c) 2010, Oracle America, Inc. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of the "Oracle America, Inc." nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * rpc_scan.h, Definitions for the RPCL scanner */ /* * kinds of tokens */ enum tok_kind { TOK_IDENT, TOK_CHARCONST, TOK_STRCONST, TOK_LPAREN, TOK_RPAREN, TOK_LBRACE, TOK_RBRACE, TOK_LBRACKET, TOK_RBRACKET, TOK_LANGLE, TOK_RANGLE, TOK_STAR, TOK_COMMA, TOK_EQUAL, TOK_COLON, TOK_SEMICOLON, TOK_CONST, TOK_STRUCT, TOK_UNION, TOK_SWITCH, TOK_CASE, TOK_DEFAULT, TOK_ENUM, TOK_TYPEDEF, TOK_INT, TOK_SHORT, TOK_LONG, TOK_HYPER, TOK_UNSIGNED, TOK_FLOAT, TOK_DOUBLE, TOK_OPAQUE, TOK_CHAR, TOK_STRING, TOK_BOOL, TOK_VOID, TOK_PROGRAM, TOK_VERSION, TOK_EOF }; typedef enum tok_kind tok_kind; /* * a token */ struct token { tok_kind kind; const char *str; }; typedef struct token token; /* * routine interface */ void scan(tok_kind expect, token *tokp); void scan2(tok_kind expect1, tok_kind expect2, token *tokp); void scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp); void scan_num(token *tokp); void peek(token *tokp); int peekscan(tok_kind expect, token *tokp); void get_token(token *tokp); void expected1(tok_kind exp1) __attribute__ ((noreturn)); void expected2(tok_kind exp1, tok_kind exp2) __attribute__ ((noreturn)); void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3) __attribute__ ((noreturn));
28.142857
78
0.735364
87674ea5bce24941469e925238650fbedcf98071
15,687
h
C
include/winnetwk.h
milo1023/winecx
5c3fef5b8175fffa37962fb4df2a282a21201db0
[ "MIT" ]
23
2020-04-09T07:11:45.000Z
2022-03-31T10:06:31.000Z
include/winnetwk.h
milo1023/winecx
5c3fef5b8175fffa37962fb4df2a282a21201db0
[ "MIT" ]
2
2021-05-21T06:25:34.000Z
2021-05-22T11:27:24.000Z
include/winnetwk.h
milo1023/winecx
5c3fef5b8175fffa37962fb4df2a282a21201db0
[ "MIT" ]
7
2020-11-13T02:34:21.000Z
2022-01-06T15:24:03.000Z
/* * Copyright (C) the Wine project * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef _WINNETWK_H_ #define _WINNETWK_H_ #include "wine/winheader_enter.h" #ifdef __cplusplus extern "C" { #endif /* * Network types */ #define WNNC_NET_MSNET 0x00010000 #define WNNC_NET_LANMAN 0x00020000 #define WNNC_NET_NETWARE 0x00030000 #define WNNC_NET_VINES 0x00040000 #define WNNC_NET_10NET 0x00050000 #define WNNC_NET_LOCUS 0x00060000 #define WNNC_NET_SUN_PC_NFS 0x00070000 #define WNNC_NET_LANSTEP 0x00080000 #define WNNC_NET_9TILES 0x00090000 #define WNNC_NET_LANTASTIC 0x000A0000 #define WNNC_NET_AS400 0x000B0000 #define WNNC_NET_FTP_NFS 0x000C0000 #define WNNC_NET_PATHWORKS 0x000D0000 #define WNNC_NET_LIFENET 0x000E0000 #define WNNC_NET_POWERLAN 0x000F0000 #define WNNC_NET_BWNFS 0x00100000 #define WNNC_NET_COGENT 0x00110000 #define WNNC_NET_FARALLON 0x00120000 #define WNNC_NET_APPLETALK 0x00130000 #define WNNC_NET_INTERGRAPH 0x00140000 /* * Network resources */ #define RESOURCE_CONNECTED 0x00000001 #define RESOURCE_GLOBALNET 0x00000002 #define RESOURCE_REMEMBERED 0x00000003 #define RESOURCE_RECENT 0x00000004 #define RESOURCE_CONTEXT 0x00000005 #define RESOURCETYPE_ANY 0x00000000 #define RESOURCETYPE_DISK 0x00000001 #define RESOURCETYPE_PRINT 0x00000002 #define RESOURCETYPE_RESERVED 0x00000008 #define RESOURCETYPE_UNKNOWN 0xFFFFFFFF #define RESOURCEUSAGE_CONNECTABLE 0x00000001 #define RESOURCEUSAGE_CONTAINER 0x00000002 #define RESOURCEUSAGE_NOLOCALDEVICE 0x00000004 #define RESOURCEUSAGE_SIBLING 0x00000008 #define RESOURCEUSAGE_ATTACHED 0x00000010 #define RESOURCEUSAGE_ALL (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED) #define RESOURCEUSAGE_RESERVED 0x80000000 #define RESOURCEDISPLAYTYPE_GENERIC 0x00000000 #define RESOURCEDISPLAYTYPE_DOMAIN 0x00000001 #define RESOURCEDISPLAYTYPE_SERVER 0x00000002 #define RESOURCEDISPLAYTYPE_SHARE 0x00000003 #define RESOURCEDISPLAYTYPE_FILE 0x00000004 #define RESOURCEDISPLAYTYPE_GROUP 0x00000005 #define RESOURCEDISPLAYTYPE_NETWORK 0x00000006 #define RESOURCEDISPLAYTYPE_ROOT 0x00000007 #define RESOURCEDISPLAYTYPE_SHAREADMIN 0x00000008 #define RESOURCEDISPLAYTYPE_DIRECTORY 0x00000009 #define RESOURCEDISPLAYTYPE_TREE 0x0000000A typedef struct { DWORD dwScope; DWORD dwType; DWORD dwDisplayType; DWORD dwUsage; LPSTR lpLocalName; LPSTR lpRemoteName; LPSTR lpComment ; LPSTR lpProvider; } NETRESOURCEA,*LPNETRESOURCEA; typedef struct { DWORD dwScope; DWORD dwType; DWORD dwDisplayType; DWORD dwUsage; LPWSTR lpLocalName; LPWSTR lpRemoteName; LPWSTR lpComment ; LPWSTR lpProvider; } NETRESOURCEW,*LPNETRESOURCEW; DECL_WINELIB_TYPE_AW(NETRESOURCE) DECL_WINELIB_TYPE_AW(LPNETRESOURCE) /* * Network connections */ #define NETPROPERTY_PERSISTENT 1 #define CONNECT_UPDATE_PROFILE 0x00000001 #define CONNECT_UPDATE_RECENT 0x00000002 #define CONNECT_TEMPORARY 0x00000004 #define CONNECT_INTERACTIVE 0x00000008 #define CONNECT_PROMPT 0x00000010 #define CONNECT_NEED_DRIVE 0x00000020 #define CONNECT_REFCOUNT 0x00000040 #define CONNECT_REDIRECT 0x00000080 #define CONNECT_LOCALDRIVE 0x00000100 #define CONNECT_CURRENT_MEDIA 0x00000200 DWORD WINAPI WNetAddConnectionA(LPCSTR,LPCSTR,LPCSTR); DWORD WINAPI WNetAddConnectionW(LPCWSTR,LPCWSTR,LPCWSTR); #define WNetAddConnection WINELIB_NAME_AW(WNetAddConnection) DWORD WINAPI WNetAddConnection2A(LPNETRESOURCEA,LPCSTR,LPCSTR,DWORD); DWORD WINAPI WNetAddConnection2W(LPNETRESOURCEW,LPCWSTR,LPCWSTR,DWORD); #define WNetAddConnection2 WINELIB_NAME_AW(WNetAddConnection2) DWORD WINAPI WNetAddConnection3A(HWND,LPNETRESOURCEA,LPCSTR,LPCSTR,DWORD); DWORD WINAPI WNetAddConnection3W(HWND,LPNETRESOURCEW,LPCWSTR,LPCWSTR,DWORD); #define WNetAddConnection3 WINELIB_NAME_AW(WNetAddConnection3) DWORD WINAPI WNetCancelConnectionA(LPCSTR,BOOL); DWORD WINAPI WNetCancelConnectionW(LPCWSTR,BOOL); #define WNetCancelConnection WINELIB_NAME_AW(WNetCancelConnection) DWORD WINAPI WNetCancelConnection2A(LPCSTR,DWORD,BOOL); DWORD WINAPI WNetCancelConnection2W(LPCWSTR,DWORD,BOOL); #define WNetCancelConnection2 WINELIB_NAME_AW(WNetCancelConnection2) DWORD WINAPI WNetGetConnectionA(LPCSTR,LPSTR,LPDWORD); DWORD WINAPI WNetGetConnectionW(LPCWSTR,LPWSTR,LPDWORD); #define WNetGetConnection WINELIB_NAME_AW(WNetGetConnection) DWORD WINAPI WNetGetLastErrorA(LPDWORD,LPSTR,DWORD,LPSTR,DWORD); DWORD WINAPI WNetGetLastErrorW(LPDWORD,LPWSTR,DWORD,LPWSTR,DWORD); #define WNetGetLastError WINELIB_NAME_AW(WNetGetLastError) DWORD WINAPI WNetRestoreConnectionA(HWND,LPCSTR); DWORD WINAPI WNetRestoreConnectionW(HWND,LPCWSTR); #define WNetRestoreConnection WINELIB_NAME_AW(WNetRestoreConnection) DWORD WINAPI WNetUseConnectionA(HWND,LPNETRESOURCEA,LPCSTR,LPCSTR,DWORD,LPSTR,LPDWORD,LPDWORD); DWORD WINAPI WNetUseConnectionW(HWND,LPNETRESOURCEW,LPCWSTR,LPCWSTR,DWORD,LPWSTR,LPDWORD,LPDWORD); #define WNetUseConnection WINELIB_NAME_AW(WNetUseConnection) DWORD WINAPI WNetSetConnectionA(LPCSTR,DWORD,LPVOID); DWORD WINAPI WNetSetConnectionW(LPCWSTR,DWORD,LPVOID); #define WNetSetConnection WINELIB_NAME_AW(WNetSetConnection) /* * Network connection dialogs */ typedef struct { DWORD cbStructure; /* size of this structure in bytes */ HWND hwndOwner; /* owner window for the dialog */ LPNETRESOURCEA lpConnRes;/* Requested Resource info */ DWORD dwFlags; /* flags (see below) */ DWORD dwDevNum; /* number of devices connected to */ } CONNECTDLGSTRUCTA, *LPCONNECTDLGSTRUCTA; typedef struct { DWORD cbStructure; /* size of this structure in bytes */ HWND hwndOwner; /* owner window for the dialog */ LPNETRESOURCEW lpConnRes;/* Requested Resource info */ DWORD dwFlags; /* flags (see below) */ DWORD dwDevNum; /* number of devices connected to */ } CONNECTDLGSTRUCTW, *LPCONNECTDLGSTRUCTW; DECL_WINELIB_TYPE_AW(CONNECTDLGSTRUCT) DECL_WINELIB_TYPE_AW(LPCONNECTDLGSTRUCT) #define CONNDLG_RO_PATH 0x00000001 /* Resource path should be read-only */ #define CONNDLG_CONN_POINT 0x00000002 /* Netware -style movable connection point enabled */ #define CONNDLG_USE_MRU 0x00000004 /* Use MRU combobox */ #define CONNDLG_HIDE_BOX 0x00000008 /* Hide persistent connect checkbox */ #define CONNDLG_PERSIST 0x00000010 /* Force persistent connection */ #define CONNDLG_NOT_PERSIST 0x00000020 /* Force connection NOT persistent */ typedef struct { DWORD cbStructure; /* size of this structure in bytes */ HWND hwndOwner; /* owner window for the dialog */ LPSTR lpLocalName; /* local device name */ LPSTR lpRemoteName; /* network resource name */ DWORD dwFlags; /* flags */ } DISCDLGSTRUCTA, *LPDISCDLGSTRUCTA; typedef struct { DWORD cbStructure; /* size of this structure in bytes */ HWND hwndOwner; /* owner window for the dialog */ LPWSTR lpLocalName; /* local device name */ LPWSTR lpRemoteName; /* network resource name */ DWORD dwFlags; /* flags */ } DISCDLGSTRUCTW, *LPDISCDLGSTRUCTW; DECL_WINELIB_TYPE_AW(DISCDLGSTRUCT) DECL_WINELIB_TYPE_AW(LPDISCDLGSTRUCT) #define DISC_UPDATE_PROFILE 0x00000001 #define DISC_NO_FORCE 0x00000040 DWORD WINAPI WNetConnectionDialog(HWND,DWORD); DWORD WINAPI WNetDisconnectDialog(HWND,DWORD); DWORD WINAPI WNetConnectionDialog1A(LPCONNECTDLGSTRUCTA); DWORD WINAPI WNetConnectionDialog1W(LPCONNECTDLGSTRUCTW); #define WNetConnectionDialog1 WINELIB_NAME_AW(WNetConnectionDialog1) DWORD WINAPI WNetDisconnectDialog1A(LPDISCDLGSTRUCTA); DWORD WINAPI WNetDisconnectDialog1W(LPDISCDLGSTRUCTW); #define WNetDisconnectDialog1 WINELIB_NAME_AW(WNetDisconnectDialog1) /* * Network browsing */ DWORD WINAPI WNetOpenEnumA(DWORD,DWORD,DWORD,LPNETRESOURCEA,LPHANDLE); DWORD WINAPI WNetOpenEnumW(DWORD,DWORD,DWORD,LPNETRESOURCEW,LPHANDLE); #define WNetOpenEnum WINELIB_NAME_AW(WNetOpenEnum) DWORD WINAPI WNetEnumResourceA(HANDLE,LPDWORD,LPVOID,LPDWORD); DWORD WINAPI WNetEnumResourceW(HANDLE,LPDWORD,LPVOID,LPDWORD); #define WNetEnumResource WINELIB_NAME_AW(WNetEnumResource) DWORD WINAPI WNetGetResourceInformationA(LPNETRESOURCEA,LPVOID,LPDWORD,LPSTR*); DWORD WINAPI WNetGetResourceInformationW(LPNETRESOURCEW,LPVOID,LPDWORD,LPWSTR*); #define WNetGetResourceInformation WINELIB_NAME_AW(WNetGetResourceInformation) DWORD WINAPI WNetGetResourceParentA(LPNETRESOURCEA,LPVOID,LPDWORD); DWORD WINAPI WNetGetResourceParentW(LPNETRESOURCEW,LPVOID,LPDWORD); #define WNetGetResourceParent WINELIB_NAME_AW(WNetGetResourceParent) DWORD WINAPI WNetCloseEnum(HANDLE); /* * Universal naming */ #define UNIVERSAL_NAME_INFO_LEVEL 0x00000001 #define REMOTE_NAME_INFO_LEVEL 0x00000002 typedef struct { LPSTR lpUniversalName; } UNIVERSAL_NAME_INFOA, *LPUNIVERSAL_NAME_INFOA; typedef struct { LPWSTR lpUniversalName; } UNIVERSAL_NAME_INFOW, *LPUNIVERSAL_NAME_INFOW; DECL_WINELIB_TYPE_AW(UNIVERSAL_NAME_INFO) DECL_WINELIB_TYPE_AW(LPUNIVERSAL_NAME_INFO) typedef struct { LPSTR lpUniversalName; LPSTR lpConnectionName; LPSTR lpRemainingPath; }REMOTE_NAME_INFOA, *LPREMOTE_NAME_INFOA; typedef struct { LPWSTR lpUniversalName; LPWSTR lpConnectionName; LPWSTR lpRemainingPath; }REMOTE_NAME_INFOW, *LPREMOTE_NAME_INFOW; DECL_WINELIB_TYPE_AW(REMOTE_NAME_INFO) DECL_WINELIB_TYPE_AW(LPREMOTE_NAME_INFO) DWORD WINAPI WNetGetUniversalNameA(LPCSTR,DWORD,LPVOID,LPDWORD); DWORD WINAPI WNetGetUniversalNameW(LPCWSTR,DWORD,LPVOID,LPDWORD); #define WNetGetUniversalName WINELIB_NAME_AW(WNetGetUniversalName) /* * Other */ DWORD WINAPI WNetGetUserA(LPCSTR,LPSTR,LPDWORD); DWORD WINAPI WNetGetUserW(LPCWSTR,LPWSTR,LPDWORD); #define WNetGetUser WINELIB_NAME_AW(WNetGetUser) #define WNFMT_MULTILINE 0x01 #define WNFMT_ABBREVIATED 0x02 #define WNFMT_INENUM 0x10 #define WNFMT_CONNECTION 0x20 DWORD WINAPI WNetGetProviderNameA(DWORD,LPSTR,LPDWORD); DWORD WINAPI WNetGetProviderNameW(DWORD,LPWSTR,LPDWORD); #define WNetGetProviderName WINELIB_NAME_AW(WNetGetProviderName) typedef struct { DWORD cbStructure; DWORD dwProviderVersion; DWORD dwStatus; DWORD dwCharacteristics; DWORD dwHandle; WORD wNetType; DWORD dwPrinters; DWORD dwDrives; } NETINFOSTRUCT, *LPNETINFOSTRUCT; #define NETINFO_DLL16 0x00000001 #define NETINFO_DISKRED 0x00000004 #define NETINFO_PRINTERRED 0x00000008 DWORD WINAPI WNetGetNetworkInformationA(LPCSTR,LPNETINFOSTRUCT); DWORD WINAPI WNetGetNetworkInformationW(LPCWSTR,LPNETINFOSTRUCT); #define WNetGetNetworkInformation WINELIB_NAME_AW(WNetGetNetworkInformation) /* * Status codes */ #define WN_SUCCESS NO_ERROR #define WN_NO_ERROR NO_ERROR #define WN_NOT_SUPPORTED ERROR_NOT_SUPPORTED #define WN_CANCEL ERROR_CANCELLED #define WN_RETRY ERROR_RETRY #define WN_NET_ERROR ERROR_UNEXP_NET_ERR #define WN_MORE_DATA ERROR_MORE_DATA #define WN_BAD_POINTER ERROR_INVALID_ADDRESS #define WN_BAD_VALUE ERROR_INVALID_PARAMETER #define WN_BAD_USER ERROR_BAD_USERNAME #define WN_BAD_PASSWORD ERROR_INVALID_PASSWORD #define WN_ACCESS_DENIED ERROR_ACCESS_DENIED #define WN_FUNCTION_BUSY ERROR_BUSY #define WN_WINDOWS_ERROR ERROR_UNEXP_NET_ERR #define WN_OUT_OF_MEMORY ERROR_NOT_ENOUGH_MEMORY #define WN_NO_NETWORK ERROR_NO_NETWORK #define WN_EXTENDED_ERROR ERROR_EXTENDED_ERROR #define WN_BAD_LEVEL ERROR_INVALID_LEVEL #define WN_BAD_HANDLE ERROR_INVALID_HANDLE #define WN_NOT_INITIALIZING ERROR_ALREADY_INITIALIZED #define WN_NO_MORE_DEVICES ERROR_NO_MORE_DEVICES #define WN_NOT_CONNECTED ERROR_NOT_CONNECTED #define WN_OPEN_FILES ERROR_OPEN_FILES #define WN_DEVICE_IN_USE ERROR_DEVICE_IN_USE #define WN_BAD_NETNAME ERROR_BAD_NET_NAME #define WN_BAD_LOCALNAME ERROR_BAD_DEVICE #define WN_ALREADY_CONNECTED ERROR_ALREADY_ASSIGNED #define WN_DEVICE_ERROR ERROR_GEN_FAILURE #define WN_CONNECTION_CLOSED ERROR_CONNECTION_UNAVAIL #define WN_NO_NET_OR_BAD_PATH ERROR_NO_NET_OR_BAD_PATH #define WN_BAD_PROVIDER ERROR_BAD_PROVIDER #define WN_CANNOT_OPEN_PROFILE ERROR_CANNOT_OPEN_PROFILE #define WN_BAD_PROFILE ERROR_BAD_PROFILE #define WN_BAD_DEV_TYPE ERROR_BAD_DEV_TYPE #define WN_DEVICE_ALREADY_REMEMBERED ERROR_DEVICE_ALREADY_REMEMBERED #define WN_NO_MORE_ENTRIES ERROR_NO_MORE_ITEMS #define WN_NOT_CONTAINER ERROR_NOT_CONTAINER #define WN_NOT_AUTHENTICATED ERROR_NOT_AUTHENTICATED #define WN_NOT_LOGGED_ON ERROR_NOT_LOGGED_ON #define WN_NOT_VALIDATED ERROR_NO_LOGON_SERVERS /* * Multinet (for Shell) */ typedef struct { DWORD cbStructure; DWORD dwFlags; DWORD dwSpeed; DWORD dwDelay; DWORD dwOptDataSize; } NETCONNECTINFOSTRUCT,*LPNETCONNECTINFOSTRUCT; #define WNCON_FORNETCARD 0x00000001 #define WNCON_NOTROUTED 0x00000002 #define WNCON_SLOWLINK 0x00000004 #define WNCON_DYNAMIC 0x00000008 DWORD WINAPI MultinetGetConnectionPerformanceA(LPNETRESOURCEA,LPNETCONNECTINFOSTRUCT); DWORD WINAPI MultinetGetConnectionPerformanceW(LPNETRESOURCEW,LPNETCONNECTINFOSTRUCT); #define MultinetGetConnectionPerformance WINELIB_NAME_AW(MultinetGetConnectionPerformance) DWORD WINAPI MultinetGetErrorTextA(DWORD,DWORD,DWORD); DWORD WINAPI MultinetGetErrorTextW(DWORD,DWORD,DWORD); #define MultinetGetErrorText WINELIB_NAME_AW(MultinetGetErrorText) /* * Password cache */ /* WNetEnumCachedPasswords */ typedef struct tagPASSWORD_CACHE_ENTRY { WORD cbEntry; WORD cbResource; WORD cbPassword; BYTE iEntry; BYTE nType; BYTE abResource[1]; } PASSWORD_CACHE_ENTRY; typedef BOOL (CALLBACK *ENUMPASSWORDPROC)(PASSWORD_CACHE_ENTRY *, DWORD); UINT WINAPI WNetEnumCachedPasswords( LPSTR, WORD, BYTE, ENUMPASSWORDPROC, DWORD); DWORD WINAPI WNetGetCachedPassword( LPSTR, WORD, LPSTR, LPWORD, BYTE ); DWORD WINAPI WNetCachePassword( LPSTR, WORD, LPSTR, WORD, BYTE, WORD ); #ifdef __cplusplus } #endif #include "wine/winheader_exit.h" #endif /* _WINNETWK_H_ */
37.983051
114
0.760949
6eb23b8c793409842a44baf36e5d48e019f4857c
500
h
C
include/objects/imagedata/imagedatabase.h
henlo-birb/lovepotion
3b7128f0683252915cd0178a3e028a553b01fdc1
[ "0BSD" ]
38
2021-11-05T10:17:28.000Z
2022-03-26T09:19:41.000Z
include/objects/imagedata/imagedatabase.h
henlo-birb/lovepotion
3b7128f0683252915cd0178a3e028a553b01fdc1
[ "0BSD" ]
10
2021-11-06T04:44:49.000Z
2022-03-18T17:23:09.000Z
include/objects/imagedata/imagedatabase.h
henlo-birb/lovepotion
3b7128f0683252915cd0178a3e028a553b01fdc1
[ "0BSD" ]
5
2022-01-04T20:38:35.000Z
2022-02-28T01:11:56.000Z
#pragma once #include "common/data.h" #include "common/pixelformat.h" namespace love { class ImageDataBase : public Data { public: ~ImageDataBase() {}; PixelFormat GetFormat() const; int GetWidth() const; int GetHeight() const; virtual bool IsSRGB() const = 0; protected: ImageDataBase(PixelFormat format, int width, int height); PixelFormat format; int width; int height; }; } // namespace love
17.241379
65
0.594
09c0e952de6b06e5f6c2d3300a0e80e4afa6f327
905
h
C
Project/Zombienator/TextureFactory.h
Jallah123/TheZombienator
efbcb93b0b2943cd9b38ac84fe8a6857e329b05b
[ "MIT" ]
null
null
null
Project/Zombienator/TextureFactory.h
Jallah123/TheZombienator
efbcb93b0b2943cd9b38ac84fe8a6857e329b05b
[ "MIT" ]
null
null
null
Project/Zombienator/TextureFactory.h
Jallah123/TheZombienator
efbcb93b0b2943cd9b38ac84fe8a6857e329b05b
[ "MIT" ]
null
null
null
#pragma once #include <map> #include <string> #include <SDL_image.h> #include <SDL_ttf.h> #include "Program.h" #include "FontEnum.cpp" using std::string; class TextureFactory { public: static std::pair<SDL_Texture*, SDL_Rect> GenerateText(std::string text, int fontSize, int xPos, int yPos, FontEnum fontEnum, SDL_Color color = { 0,0,0 }, int multipleLinesSize = 0); static SDL_Texture* CreateTexture(string url); static std::pair<SDL_Texture*, SDL_Rect> CreateText(string text, SDL_Color color = { 0,0,0 }, FontEnum font = FontEnum::ROBOTO, int fontSize = 13); static std::pair<SDL_Texture*, SDL_Rect> CreateText(string text, SDL_Point position, SDL_Color color = { 0,0,0 }, FontEnum font = FontEnum::ROBOTO, int fontSize = 24); private: TextureFactory(); static std::map<FontEnum, char*> FontMap; static SDL_Texture* GenerateTextureFromSurface(SDL_Surface* surface); ~TextureFactory(); };
33.518519
182
0.742541
3cae464bf4f3b4693ce4e19e38fa932cde0d4ec7
4,364
c
C
src/init.c
nort-cnc-control/ethernet_enc28j60
6beca1d517c2b4c003e3b7ad6a8ba39cbdf4791e
[ "MIT" ]
null
null
null
src/init.c
nort-cnc-control/ethernet_enc28j60
6beca1d517c2b4c003e3b7ad6a8ba39cbdf4791e
[ "MIT" ]
null
null
null
src/init.c
nort-cnc-control/ethernet_enc28j60
6beca1d517c2b4c003e3b7ad6a8ba39cbdf4791e
[ "MIT" ]
null
null
null
#include <enc28j60.h> #include <registers.h> #include <control.h> const uint8_t enc28j60_eth_bcast[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; void enc28j60_init(struct enc28j60_state_s *state, void (*hard_reset)(bool rst), uint8_t (*spi_read_write)(uint8_t data), void (*spi_set_cs)(bool val), void (*spi_write_buf)(const uint8_t *, size_t), void (*spi_read_buf)(uint8_t *, size_t)) { state->hard_reset = hard_reset; state->spi_rw = spi_read_write; state->spi_cs = spi_set_cs; state->spi_write = spi_write_buf; state->spi_read = spi_read_buf; } bool enc28j60_detect(struct enc28j60_state_s *state) { int revid = enc28j60_read_register8(state, EREVID); if (revid == 0xFF || revid == 0x00) return false; uint16_t phid1 = enc28j60_read_phy_register16(state, PHID1); uint16_t phid2 = enc28j60_read_phy_register16(state, PHID2); if (phid1 != 0x0083) return false; return true; } bool enc28j60_configure(struct enc28j60_state_s *state, const uint8_t *mac, uint16_t rx_buffer_size, bool full_duplex) { int i; state->recv_buffer_size = rx_buffer_size; state->recv_buffer_start = 0; state->recv_buffer_last = (rx_buffer_size-1) & 0x1FFF; state->send_buffer_start = rx_buffer_size; state->send_buffer_last = 0x1FFF; enc28j60_hard_reset(state); enc28j60_reset(state); enc28j60_phy_reset(state); if (!enc28j60_detect(state)) return false; enc28j60_enable_rx(state, 0); enc28j60_write_register16(state, ERXSTL, 0); enc28j60_write_register16(state, ERXNDL, state->recv_buffer_last); enc28j60_set_bits8(state, ECON2, 1 << 7); // auto increment pointer wher r / w enc28j60_write_register16(state, ERXWRPTL, 0); enc28j60_write_register16(state, ERXRDPTL, 0); while (enc28j60_read_register8(state, EPKTCNT) > 0) enc28j60_set_bits8(state, ECON2, 1<<6); // See ENC28J60 datasheet // 6.0 Initialization // clear MACON2 enc28j60_write_register8(state, MACON2, 0x00); // set MARXEN enc28j60_set_bits8(state, MACON1, 1 << 0); // set RXPAUS and TXPAUS enc28j60_set_bits8(state, MACON1, (1 << 2) | (1 << 3)); // set PADCFG to 64 bytes padding and TXCRCEN=1 enc28j60_write_register8(state, MACON3, (1 << 7) | (1 << 6) | (1 << 5) | (1 << 4) | (0 << 3) | (0 << 2) | (0 << 1) | (0 << 0)); // DEFER=1 - in half duplex wait for medium released enc28j60_set_bits8(state, MACON4, 1 << 6); // set MAMXFL = 1518 enc28j60_write_register16(state, MAMXFLL, 1518); // Set gaps if (full_duplex) { enc28j60_write_register8(state, MABBIPG, 0x15); enc28j60_write_register16(state, MAIPGL, 0x0012); } else { enc28j60_write_register8(state, MABBIPG, 0x12); enc28j60_write_register16(state, MAIPGL, 0x0C12); } // drop own packets in half-duplex if (!full_duplex) { enc28j60_set_phy_bits16(state, PHCON2, (1 << 8)); } // Set half / full duplex if (full_duplex) { enc28j60_set_phy_bits16(state, PHCON1, (1 << 8)); enc28j60_set_bits8(state, MACON3, 1 << 0); } else { enc28j60_clear_phy_bits16(state, PHCON1, (1 << 8)); enc28j60_clear_bits8(state, MACON3, 1 << 0); } // Set LED config enc28j60_clear_phy_bits16(state, PHLCON, (0xF << 8) | (0xF << 4)); enc28j60_set_phy_bits16(state, PHLCON, (0x4 << 8) | (0x7 << 4)); // set MAC address uint16_t regs[6] = {MAADR1, MAADR2, MAADR3, MAADR4, MAADR5, MAADR6}; for (i = 0; i < 6; i++) { enc28j60_write_register8(state, regs[i], mac[i]); uint8_t check = enc28j60_read_register8(state, regs[i]); if (check != mac[i]) return false; } state->read_ptr = state->recv_buffer_start; // enable RX enc28j60_enable_rx(state, 1); return true; } void enc28j60_interrupt_enable(struct enc28j60_state_s *state, bool enable) { if (enable) { // enable INT and PKT enc28j60_set_bits8(state, EIE, (1 << 7) | (1 << 6)); } else { // disable INT and PKT enc28j60_clear_bits8(state, EIE, (1 << 7) | (1 << 6)); } }
29.093333
131
0.618011
48b45428e73b847168387ee7656e9e294c176c01
1,018
h
C
CJHookDemo/Pods/CJMedia/CJMedia/CJUploadImagePickerUtil/Models/CJVideoUploadFileModelsOwner.h
dvlproad/005-UIKit-List-iOS
34a9b2e17f98f6484c119c33a6e6e88fbfac15bd
[ "MIT" ]
59
2018-08-16T10:09:52.000Z
2022-02-16T05:43:45.000Z
CJHookDemo/Pods/CJMedia/CJMedia/CJUploadImagePickerUtil/Models/CJVideoUploadFileModelsOwner.h
dvlproad/005-UIKit-List-iOS
34a9b2e17f98f6484c119c33a6e6e88fbfac15bd
[ "MIT" ]
null
null
null
CJHookDemo/Pods/CJMedia/CJMedia/CJUploadImagePickerUtil/Models/CJVideoUploadFileModelsOwner.h
dvlproad/005-UIKit-List-iOS
34a9b2e17f98f6484c119c33a6e6e88fbfac15bd
[ "MIT" ]
15
2018-11-09T01:49:32.000Z
2022-02-14T14:56:12.000Z
// // CJVideoUploadFileModelsOwner.h // CJPickerDemo // // Created by ciyouzen on 2017/2/23. // Copyright © 2017年 dvlproad. All rights reserved. // #import <CJNetwork/CJUploadFileModelsOwner.h> @interface CJVideoUploadFileModelsOwner : CJUploadFileModelsOwner @property (nonatomic, strong) UIImage *image; /**< 预览图 */ @property (nonatomic, copy) NSString *imageLocalRelativePath; /**< 预览图的本地相对路径 */ @property (nonatomic, copy) NSString *videoLocalRelativePath; /**< 视频的本地相对路径 */ /** * 初始化 * * @param showImage 显示的图片 * @param imageLocalRelativePath 预览图的本地相对路径 * @param videoLocalRelativePath 视频的本地相对路径 * @param uploadFileModels 该item需要执行的上传 * * return CJVideoUploadFileModelsOwner */ - (instancetype)initWithShowImage:(UIImage *)showImage imageLocalRelativePath:(NSString *)imageLocalRelativePath videoLocalRelativePath:(NSString *)videoLocalRelativePath uploadFileModels:(NSArray<CJUploadFileModel *> *)uploadFileModels; @end
30.848485
83
0.721022
480dbd4881eb0ba1a344167afa8406277601c46b
112
h
C
13_cgo/example_14/clibrary.h
juhp/savetheworldwithgo
0fa1301f70ad24f79c267511237eb63a922296e6
[ "Apache-2.0" ]
72
2021-04-07T06:02:48.000Z
2022-03-14T08:18:41.000Z
13_cgo/example_14/clibrary.h
juhp/savetheworldwithgo
0fa1301f70ad24f79c267511237eb63a922296e6
[ "Apache-2.0" ]
1
2021-12-14T13:58:06.000Z
2021-12-14T13:58:06.000Z
13_cgo/example_14/clibrary.h
juhp/savetheworldwithgo
0fa1301f70ad24f79c267511237eb63a922296e6
[ "Apache-2.0" ]
29
2021-04-07T16:18:30.000Z
2022-03-10T09:23:42.000Z
#ifndef CLIBRARY_H #define CLIBRARY_H typedef void (*callback_f) (int); void a_callback_func(callback_f); #endif
22.4
33
0.803571
290ac5f8c7483cfbdc90c3a8d0bf89339abc3b34
410
h
C
include/NcursesGraphcisDriver.h
gangz/Tetris
782b7cb530638997d160df7e3e34c91f7391fa50
[ "MIT" ]
null
null
null
include/NcursesGraphcisDriver.h
gangz/Tetris
782b7cb530638997d160df7e3e34c91f7391fa50
[ "MIT" ]
1
2019-06-27T03:14:48.000Z
2019-06-29T15:18:34.000Z
include/NcursesGraphcisDriver.h
gangz/Tetris
782b7cb530638997d160df7e3e34c91f7391fa50
[ "MIT" ]
null
null
null
#ifndef NCURSESGRAPHCISDRIVER_H_ #define NCURSESGRAPHCISDRIVER_H_ #include "IGraphcisDriver.h" class NcursesGraphcisDriver: public IGraphcisDriver { public: NcursesGraphcisDriver(); virtual ~NcursesGraphcisDriver(); virtual void drawBox(Point left_top, Point right_bottom); virtual void writeText(Point pos, std::string text); virtual void drawCell(Point pos); }; #endif /* NCURSESGRAPHCISDRIVER_H_ */
25.625
58
0.804878
ad72f64d9f5444464927a0fe5b804b395edcd303
216
c
C
programing-languages/C/01_C_hello-world/main.c
felipecaggi/explore
8a77abf24e03856cbf433237c588c3c6c3b78978
[ "MIT" ]
null
null
null
programing-languages/C/01_C_hello-world/main.c
felipecaggi/explore
8a77abf24e03856cbf433237c588c3c6c3b78978
[ "MIT" ]
null
null
null
programing-languages/C/01_C_hello-world/main.c
felipecaggi/explore
8a77abf24e03856cbf433237c588c3c6c3b78978
[ "MIT" ]
null
null
null
/* * Author : Felipe Caggi * Date : 2018-09-28 * Description : Writes the words "Hello World" on the screen */ #include <stdio.h> int main() { printf("Hello, World!\n"); return 0; }
18
64
0.550926
093df77e76700e1a144399521fa30ebe5e3e5c15
6,368
h
C
benchmarks/lonestar/sp/sp.h
chisuhua/gem5
74694255d90e0892d5f5c4d13f6077cdb9b9cb95
[ "BSD-3-Clause" ]
null
null
null
benchmarks/lonestar/sp/sp.h
chisuhua/gem5
74694255d90e0892d5f5c4d13f6077cdb9b9cb95
[ "BSD-3-Clause" ]
null
null
null
benchmarks/lonestar/sp/sp.h
chisuhua/gem5
74694255d90e0892d5f5c4d13f6077cdb9b9cb95
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include "cutil_subset.h" struct CSRGraph { int nnodes; int nedges; int *row_offsets; int *columns; bool *sat; float *bias; bool *value; bool alloc() { assert(nnodes > 0); assert(nedges > 0); row_offsets = (int *) calloc(nnodes + 1, sizeof(*row_offsets)); columns = (int *) calloc(nedges, sizeof(*columns)); sat = (bool *) calloc(nnodes, sizeof(bool)); bias = (float *) calloc(nnodes, sizeof(float)); value = (bool *) calloc(nnodes, sizeof(bool)); return (row_offsets != NULL) && (columns != NULL) && sat && bias && value; } void set_last_offset() { row_offsets[nnodes] = nedges; } int degree(const int node) const { return row_offsets[node + 1] - row_offsets[node]; } void dump_edges() const { int i; for (i = 0; i < nedges; i++) printf("%d ", columns[i]); printf("\n"); } void dump_offsets() const { int i; for (i = 0; i < nnodes; i++) printf("%d ", row_offsets[i]); printf("\n"); } }; struct GPUCSRGraph : CSRGraph { bool alloc() { assert(nnodes > 0); assert(nedges > 0); CUDA_SAFE_CALL(cudaMalloc(&row_offsets, (nnodes + 1) * sizeof(*row_offsets))); CUDA_SAFE_CALL(cudaMalloc(&columns, nedges * sizeof(*columns))); CUDA_SAFE_CALL(cudaMalloc(&sat, nnodes * sizeof(*sat))); CUDA_SAFE_CALL(cudaMalloc(&bias, nnodes * sizeof(*bias))); CUDA_SAFE_CALL(cudaMalloc(&value, nnodes * sizeof(*value))); return (row_offsets != NULL) && (columns != NULL) && sat && bias && value; } bool from_cpu(CSRGraph &cpu) { nnodes = cpu.nnodes; nedges = cpu.nedges; assert(alloc()); CUDA_SAFE_CALL(cudaMemcpy(row_offsets, cpu.row_offsets, (nnodes + 1) * sizeof(*row_offsets), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(columns, cpu.columns, (nedges * sizeof(*columns)), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(sat, cpu.sat, (nnodes * sizeof(*sat)), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(bias, cpu.bias, (nnodes * sizeof(*bias)), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(value, cpu.value, (nnodes * sizeof(*value)), cudaMemcpyHostToDevice)); return true; } bool to_cpu(CSRGraph &cpu, bool alloc = false) { if (alloc) { cpu.nnodes = nnodes; cpu.nedges = nedges; assert(cpu.alloc()); } assert(nnodes == cpu.nnodes); assert(nedges == cpu.nedges); CUDA_SAFE_CALL(cudaMemcpy(cpu.row_offsets, row_offsets, (nnodes + 1) * sizeof(*row_offsets), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.columns, columns, nedges * sizeof(*columns), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.sat, sat, (nnodes * sizeof(*sat)), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.bias, bias, (nnodes * sizeof(*bias)), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.value, value, (nnodes * sizeof(*value)), cudaMemcpyDeviceToHost)); return true; } __device__ int degree(const int node) const { return row_offsets[node + 1] - row_offsets[node]; } }; struct Edge { int nedges; int *src; int *dst; bool *bar; float *eta; float *pi_0; float *pi_S; float *pi_U; bool alloc() { assert(nedges > 0); src = (int*) calloc(nedges, sizeof(*src)); dst = (int*) calloc(nedges, sizeof(*dst)); bar = (bool*) calloc(nedges, sizeof(*bar)); eta = (float*) calloc(nedges, sizeof(*eta)); pi_0 = (float*) calloc(nedges, sizeof(*pi_0)); pi_S = (float*) calloc(nedges, sizeof(*pi_S)); pi_U = (float*) calloc(nedges, sizeof(*pi_U)); return (src && dst && bar && eta && pi_0 && pi_S && pi_U); } }; struct GPUEdge : Edge { bool alloc() { assert(nedges > 0); CUDA_SAFE_CALL(cudaMalloc(&src, (nedges) * (sizeof(*src)))); CUDA_SAFE_CALL(cudaMalloc(&dst, (nedges) * (sizeof(*dst)))); CUDA_SAFE_CALL(cudaMalloc(&bar, (nedges) * (sizeof(*bar)))); CUDA_SAFE_CALL(cudaMalloc(&eta, (nedges) * (sizeof(*eta)))); CUDA_SAFE_CALL(cudaMalloc(&pi_0, (nedges) * (sizeof(*pi_0)))); CUDA_SAFE_CALL(cudaMalloc(&pi_S, (nedges) * (sizeof(*pi_S)))); CUDA_SAFE_CALL(cudaMalloc(&pi_U, (nedges) * (sizeof(*pi_U)))); return (src && dst && bar && eta && pi_0 && pi_S && pi_U); } bool from_cpu(Edge &cpu) { nedges = cpu.nedges; assert(alloc()); CUDA_SAFE_CALL(cudaMemcpy(src, cpu.src, (nedges) * sizeof(*src), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(dst, cpu.dst, (nedges) * sizeof(*dst), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(bar, cpu.bar, (nedges) * sizeof(*bar), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(eta, cpu.eta, (nedges) * sizeof(*eta), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(pi_0, cpu.pi_0, (nedges) * sizeof(*pi_0), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(pi_S, cpu.pi_S, (nedges) * sizeof(*pi_S), cudaMemcpyHostToDevice)); CUDA_SAFE_CALL(cudaMemcpy(pi_U, cpu.pi_U, (nedges) * sizeof(*pi_U), cudaMemcpyHostToDevice)); return true; } bool to_cpu(Edge &cpu, bool alloc = false) { if (alloc) { cpu.nedges = nedges; assert(cpu.alloc()); } assert(nedges == cpu.nedges); CUDA_SAFE_CALL(cudaMemcpy(cpu.src, src, (nedges) * sizeof(*src), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.dst, dst, (nedges) * sizeof(*dst), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.bar, bar, (nedges) * sizeof(*bar), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.eta, eta, (nedges) * sizeof(*eta), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.pi_0, pi_0, (nedges) * sizeof(*pi_0), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.pi_S, pi_S, (nedges) * sizeof(*pi_S), cudaMemcpyDeviceToHost)); CUDA_SAFE_CALL(cudaMemcpy(cpu.pi_U, pi_U, (nedges) * sizeof(*pi_U), cudaMemcpyDeviceToHost)); return true; } };
32.324873
126
0.605999
bc12637d4b3ee5fc2ab6b832d786bd5a680a5051
2,165
c
C
SCTK/src/sclite/slm_v2/src/rr_libs/rr_fwrite.c
IIP-Sogang/Audio-Visual-Speech-Recognition
bd03be91135acbc6162b83092d462b7fe71dd007
[ "MIT" ]
113
2018-11-20T06:00:39.000Z
2022-03-29T06:01:55.000Z
SCTK/src/sclite/slm_v2/src/rr_libs/rr_fwrite.c
IIP-Sogang/Audio-Visual-Speech-Recognition
bd03be91135acbc6162b83092d462b7fe71dd007
[ "MIT" ]
28
2017-09-11T16:20:26.000Z
2022-02-13T14:16:33.000Z
SCTK/src/sclite/slm_v2/src/rr_libs/rr_fwrite.c
IIP-Sogang/Audio-Visual-Speech-Recognition
bd03be91135acbc6162b83092d462b7fe71dd007
[ "MIT" ]
47
2015-01-27T06:22:57.000Z
2021-11-11T20:59:04.000Z
/* rr_fwrite(): call fwrite and quit if it fails */ /*===================================================================== ======= COPYRIGHT NOTICE ======= Copyright (C) 1994, Carnegie Mellon University and Ronald Rosenfeld. All rights reserved. This software is made available for research purposes only. It may be redistributed freely for this purpose, in full or in part, provided that this entire copyright notice is included on any copies of this software and applications and derivations thereof. This software is provided on an "as is" basis, without warranty of any kind, either expressed or implied, as to any matter including, but not limited to warranty of fitness of purpose, or merchantability, or results obtained from use of this software. ======================================================================*/ /* If on a MIPS machine, write the data SWAP'ed. Roni Rosenfeld, 9/92 */ /* Edited by Philip Clarkson, March 1997 to prevent compilation warnings */ #include <stdio.h> #include "mips_swap.h" #include "general.h" void *rr_fwrite(char *ptr, int elsize, int n_elem, FILE *fp, char *header) { int n_written, i; if (n_elem > 0) { if (elsize == sizeof(int)) { for (i=0; i<n_elem; i++) { SWAPWORD(ptr+(elsize*i)); } } else if (elsize == sizeof(short)) { for (i=0; i<n_elem; i++) { SWAPHALF(ptr+(elsize*i)); } } else if (elsize == sizeof(double)) { for (i=0; i<n_elem; i++) { SWAPDOUBLE(ptr+(elsize*i)); } } n_written = fwrite(ptr,elsize,n_elem,fp); if (elsize == sizeof(int)) { for (i=0; i<n_elem; i++) { SWAPWORD(ptr+(elsize*i)); } } else if (elsize == sizeof(short)) { for (i=0; i<n_elem; i++) { SWAPHALF(ptr+(elsize*i)); } } else if (elsize == sizeof(double)) { for (i=0; i<n_elem; i++) { SWAPDOUBLE(ptr+(elsize*i)); } } if (n_written != n_elem) quit(-1, "rr_fwrite: problems writing %s. Only %d of %d elements were written\n", header, n_written, n_elem); } return(0); /* Not relevant, but stops compilation warnings. */ }
28.866667
79
0.5806
5d7e4a46dc8e90aa5e264b4ce3ae7659530813c6
303
h
C
PrivateFrameworks/CoreThemeDefinition.framework/TDCursorFacetDefinition.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
PrivateFrameworks/CoreThemeDefinition.framework/TDCursorFacetDefinition.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
PrivateFrameworks/CoreThemeDefinition.framework/TDCursorFacetDefinition.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/CoreThemeDefinition.framework/CoreThemeDefinition */ @interface TDCursorFacetDefinition : TDFacetDefinition - (void)copyAttributesInto:(id)arg1; - (id)copyDataFromAttributes; - (void)setAttributesFromCopyData:(id)arg1; @end
25.25
93
0.811881
95030fe56f653175dc9ed6c6ce604f2aeb8b2309
9,096
h
C
applications/MixedElementApplication/custom_strategies/convergencecriterias/mixed_element_criteria.h
lcirrott/Kratos
8406e73e0ad214c4f89df4e75e9b29d0eb4a47ea
[ "BSD-4-Clause" ]
2
2020-04-30T19:13:08.000Z
2021-04-14T19:40:47.000Z
applications/MixedElementApplication/custom_strategies/convergencecriterias/mixed_element_criteria.h
lcirrott/Kratos
8406e73e0ad214c4f89df4e75e9b29d0eb4a47ea
[ "BSD-4-Clause" ]
1
2020-04-30T19:19:09.000Z
2020-05-02T14:22:36.000Z
applications/MixedElementApplication/custom_strategies/convergencecriterias/mixed_element_criteria.h
lcirrott/Kratos
8406e73e0ad214c4f89df4e75e9b29d0eb4a47ea
[ "BSD-4-Clause" ]
1
2020-06-12T08:51:24.000Z
2020-06-12T08:51:24.000Z
/* ============================================================================== KratosStructuralApplication A library based on: Kratos A General Purpose Software for Multi-Physics Finite Element Analysis Version 1.0 (Released on march 05, 2007). Copyright 2007 Pooyan Dadvand, Riccardo Rossi, Janosch Stascheit, Felix Nagel pooyan@cimne.upc.edu rrossi@cimne.upc.edu janosch.stascheit@rub.de nagel@sd.rub.de - CIMNE (International Center for Numerical Methods in Engineering), Gran Capita' s/n, 08034 Barcelona, Spain - Ruhr-University Bochum, Institute for Structural Mechanics, Germany Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following condition: Distribution of this code for any commercial purpose is permissible ONLY BY DIRECT ARRANGEMENT WITH THE COPYRIGHT OWNERS. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============================================================================== */ /* ********************************************************* * * Last Modified by: $Author: janosch $ * Date: $Date: 2007-04-13 15:59:32 $ * Revision: $Revision: 1.2 $ * * ***********************************************************/ #if !defined(KRATOS_MIXED_ELEMENT_CRITERIA ) #define KRATOS_MIXED_ELEMENT_CRITERIA /* System includes */ /* External includes */ /* Project includes */ #include "includes/model_part.h" #include "includes/define.h" namespace Kratos { /**@name Kratos Globals */ /*@{ */ /*@} */ /**@name Type Definitions */ /*@{ */ /*@} */ /**@name Enum's */ /*@{ */ /*@} */ /**@name Functions */ /*@{ */ /*@} */ /**@name Kratos Classes */ /*@{ */ /** Short class definition. Detail class definition. \URL[Example of use html]{ extended_documentation/no_ex_of_use.html} \URL[Example of use pdf]{ extended_documentation/no_ex_of_use.pdf} \URL[Example of use doc]{ extended_documentation/no_ex_of_use.doc} \URL[Example of use ps]{ extended_documentation/no_ex_of_use.ps} \URL[Extended documentation html]{ extended_documentation/no_ext_doc.html} \URL[Extended documentation pdf]{ extended_documentation/no_ext_doc.pdf} \URL[Extended documentation doc]{ extended_documentation/no_ext_doc.doc} \URL[Extended documentation ps]{ extended_documentation/no_ext_doc.ps} */ template<class TSparseSpace, class TDenseSpace > class MixedElementConvergenceCriteria : public ConvergenceCriteria< TSparseSpace, TDenseSpace > { public: /**@name Type Definitions */ /*@{ */ KRATOS_CLASS_POINTER_DEFINITION( MixedElementConvergenceCriteria ); typedef ConvergenceCriteria< TSparseSpace, TDenseSpace > BaseType; typedef typename BaseType::TDataType TDataType; typedef typename BaseType::DofsArrayType DofsArrayType; typedef typename BaseType::TSystemMatrixType TSystemMatrixType; typedef typename BaseType::TSystemVectorType TSystemVectorType; /*@} */ /**@name Life Cycle */ /*@{ */ /** Constructor. */ MixedElementConvergenceCriteria( TDataType NewRatioTolerance, TDataType AlwaysConvergedNorm) : ConvergenceCriteria< TSparseSpace, TDenseSpace >() { mRatioTolerance = NewRatioTolerance; mAlwaysConvergedNorm = AlwaysConvergedNorm; //mActualizeRHSIsNeeded = false; } /** Destructor. */ virtual ~MixedElementConvergenceCriteria() { } /*@} */ /**@name Operators */ /*@{ */ /*Criterias that need to be called after getting the solution */ bool PostCriteria( ModelPart& r_model_part, DofsArrayType& rDofSet, const TSystemMatrixType& A, const TSystemVectorType& Dx, const TSystemVectorType& b ) { if (Dx.size() != 0) //if we are solving for something { double delta_disp_norm = 0.0; double disp_norm = 0.0; double delta_stress_norm = 0.0; double stress_norm = 0.0; for (typename DofsArrayType::iterator i_dof = rDofSet.begin(); i_dof != rDofSet.end(); ++i_dof) { if (i_dof->IsFree()) { if (i_dof->GetVariable() == DISPLACEMENT_X || i_dof->GetVariable() == DISPLACEMENT_Y || i_dof->GetVariable() == DISPLACEMENT_Z) { delta_disp_norm += Dx[i_dof->EquationId()] * Dx[i_dof->EquationId()]; disp_norm += pow( i_dof->GetSolutionStepValue() - i_dof->GetSolutionStepValue(1) , 2); } else { delta_stress_norm += Dx[i_dof->EquationId()] * Dx[i_dof->EquationId()]; stress_norm += i_dof->GetSolutionStepValue() * i_dof->GetSolutionStepValue(); } } } delta_disp_norm = sqrt(delta_disp_norm); disp_norm = sqrt(disp_norm+1e-20); delta_stress_norm = sqrt(delta_stress_norm); stress_norm = sqrt(stress_norm); double disp_ratio = delta_disp_norm / disp_norm; double stress_ratio = delta_stress_norm / stress_norm; std::cout << "delta_disp_norm = " << delta_disp_norm << "; disp_norm = " << disp_norm << std::endl; std::cout << "delta_stress_norm = " << delta_stress_norm << "; stress_norm = " << stress_norm << std::endl; std::cout << "DISPLACEMENTS :: disp ratio = " << disp_ratio << "; Expected ratio = " << mRatioTolerance << "Absolute tol reached = " << delta_disp_norm << std::endl; std::cout << "OTHER :: ratio = " << stress_ratio << "; Expected ratio = " << mRatioTolerance << "Absolute tol reached = " << delta_stress_norm << std::endl; if ( (disp_ratio < mRatioTolerance || delta_disp_norm < mAlwaysConvergedNorm) /* && (delta_stress_norm < mRatioTolerance || delta_stress_norm < mAlwaysConvergedNorm)*/ ) { std::cout << "Congratulations the time step solution is converged..." << std::endl; return true; } else { return false; } } return true; } void Initialize( ModelPart & r_model_part ) { } void InitializeSolutionStep( ModelPart& r_model_part, DofsArrayType& rDofSet, const TSystemMatrixType& A, const TSystemVectorType& Dx, const TSystemVectorType & b ) { } void FinalizeSolutionStep( ModelPart& r_model_part, DofsArrayType& rDofSet, const TSystemMatrixType& A, const TSystemVectorType& Dx, const TSystemVectorType & b ) { } /*@} */ /**@name Operations */ /*@{ */ /*@} */ /**@name Access */ /*@{ */ /*@} */ /**@name Inquiry */ /*@{ */ /*@} */ /**@name Friends */ /*@{ */ /*@} */ protected: /**@name Protected static Member Variables */ /*@{ */ /*@} */ /**@name Protected member Variables */ /*@{ */ /*@} */ /**@name Protected Operators*/ /*@{ */ /*@} */ /**@name Protected Operations*/ /*@{ */ /*@} */ /**@name Protected Access */ /*@{ */ /*@} */ /**@name Protected Inquiry */ /*@{ */ /*@} */ /**@name Protected LifeCycle */ /*@{ */ /*@} */ private: /**@name Static Member Variables */ /*@{ */ /*@} */ /**@name Member Variables */ /*@{ */ TDataType mRatioTolerance; TDataType mAlwaysConvergedNorm; /*@} */ /**@name Private Operators*/ /*@{ */ /*@} */ /**@name Private Operations*/ /*@{ */ /*@} */ /**@name Private Access */ /*@{ */ /*@} */ /**@name Private Inquiry */ /*@{ */ /*@} */ /**@name Un accessible methods */ /*@{ */ /*@} */ }; /* Class ClassName */ /*@} */ /**@name Type Definitions */ /*@{ */ /*@} */ } /* namespace Kratos.*/ #endif /* KRATOS_MIXED_ELEMENT_CRITERIA defined */
24.127321
182
0.577177
e549b207b320c4a6fba823b1bea5bcc4af2a91a3
692
h
C
iOS/BitmovinPlayer.framework/Headers/BMPPlayingEvent.h
bitmovin/bitmovin-player-ios-sdk-cocoapod
b6f540d1ff74d28cfabc2be1ce6f0a81748f6166
[ "Info-ZIP" ]
5
2018-04-09T21:01:07.000Z
2020-05-15T15:05:23.000Z
iOS/BitmovinPlayer.framework/Headers/BMPPlayingEvent.h
bitmovin/bitmovin-player-ios-sdk-cocoapod
b6f540d1ff74d28cfabc2be1ce6f0a81748f6166
[ "Info-ZIP" ]
30
2018-02-10T09:33:06.000Z
2022-03-03T07:40:50.000Z
tvOS/BitmovinPlayer.framework/Headers/BMPPlayingEvent.h
bitmovin/bitmovin-player-ios-sdk-cocoapod
b6f540d1ff74d28cfabc2be1ce6f0a81748f6166
[ "Info-ZIP" ]
6
2018-09-19T14:58:18.000Z
2021-02-19T16:23:02.000Z
// // Bitmovin Player iOS SDK // Copyright (C) 2019, Bitmovin GmbH, All Rights Reserved // // This source code and its use and distribution, is subject to the terms // and conditions of the applicable license agreement. // #import <BitmovinPlayer/BMPPlayerEvent.h> NS_ASSUME_NONNULL_BEGIN /** * See BMPPlayerListener.h for more information on this event. */ NS_SWIFT_NAME(PlayingEvent) @interface BMPPlayingEvent : BMPPlayerEvent @property (nonatomic, readonly) NSTimeInterval time; /// :nodoc: - (instancetype)init NS_UNAVAILABLE; /// :nodoc: + (instancetype)new NS_UNAVAILABLE; - (instancetype)initWithTime:(NSTimeInterval)time NS_DESIGNATED_INITIALIZER; @end NS_ASSUME_NONNULL_END
23.862069
76
0.777457
05f5f687d6e28cb5ed759be3b86e865bb4b52cb0
2,620
h
C
featurematcher.h
nirajbasnet/360video_stitching
cd40f20536abb085cba7317c8730a3bd6f9d263e
[ "MIT" ]
12
2019-04-18T03:39:56.000Z
2021-11-30T12:33:22.000Z
featurematcher.h
nirajbasnet/360video_stitching
cd40f20536abb085cba7317c8730a3bd6f9d263e
[ "MIT" ]
null
null
null
featurematcher.h
nirajbasnet/360video_stitching
cd40f20536abb085cba7317c8730a3bd6f9d263e
[ "MIT" ]
6
2019-05-14T01:45:20.000Z
2021-11-05T15:45:45.000Z
#include "opencv2/core.hpp" #include "opencv2/imgcodecs/imgcodecs.hpp" #include "opencv2/features2d.hpp" #include "opencv2/stitching/warpers.hpp" #include "opencv2/calib3d/calib3d.hpp" #include "opencv2/stitching/detail/matchers.hpp" #include <opencv2/stitching/detail/camera.hpp> #include "opencv2/stitching/detail/seam_finders.hpp" #include <opencv2/core/utility.hpp> #include <iostream> #include <fstream> #include <string> #include <vector> #include "opencv2/stitching/detail/camera.hpp" #include <algorithm> using namespace cv; using namespace cv::detail; using namespace std; namespace FeatureMatcher{ class Matcher{ private: std::vector<std::pair<int,int> > near_pairs; UMat mask; int num_images; double match_conf_; double conf_thresh_; public: Matcher(const int &NUM_CAMERAS, const double &match_conf_, const double &conf_thresh_, UMat &matcher_mask_); void makeMatchPair( vector<MatchesInfo> &pairwise_matches, const int NUM_CAMERAS); void match( const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info, int distanceMetric, const bool useMinDistRef, const bool useBFMatcher); void match( const std::vector<detail::ImageFeatures> &features, std::vector<MatchesInfo> &pairwise_matches, int distanceMetric, const bool useMinDistRef, const bool useBFMatcher); void matchParallel( const std::vector<ImageFeatures> &features, vector<MatchesInfo> &pairwise_matches); void computeHomography( const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info, int &num_matches_thresh1_, int &num_matches_thresh2_); void computeHomography( const vector<ImageFeatures> &features, vector<MatchesInfo> &pairwise_matches, int &num_matches_thresh1_, int &num_matches_thresh2_); void appendFeaturesAndMatches( vector<ImageFeatures> &features, vector<MatchesInfo> &pairwiseMatches, vector<ImageFeatures> &features1, vector<MatchesInfo> &pairwiseMatches1); Mat visualizeKeypointMatches( const Mat& imageL, const Mat& imageR, const MatchesInfo& matches_info, const ImageFeatures& features1, const ImageFeatures& features2); void briskFeatures(Mat image, ImageFeatures &feature, int index, Mat mask); }; }//namespace FeatureMatcher
27.578947
113
0.677481
3959296345a5d8d84b420b59f065d38f89ce927a
16,928
c
C
cmd/sbin/fsck.c
p-durlej/newsys
314956b8ca463b8d7cc9b30de2be2d4247adf432
[ "BSD-2-Clause" ]
70
2016-10-26T14:31:35.000Z
2022-01-06T15:07:29.000Z
cmd/sbin/fsck.c
p-durlej/newsys
314956b8ca463b8d7cc9b30de2be2d4247adf432
[ "BSD-2-Clause" ]
5
2017-11-10T23:08:26.000Z
2021-05-03T14:15:39.000Z
cmd/sbin/fsck.c
p-durlej/newsys
314956b8ca463b8d7cc9b30de2be2d4247adf432
[ "BSD-2-Clause" ]
12
2017-06-19T15:45:09.000Z
2022-03-24T14:50:26.000Z
/* Copyright (c) 2017, Piotr Durlej * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <priv/natfs.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <fcntl.h> #include <errno.h> #include <stdlib.h> #include <mount.h> #include <stdint.h> #include <err.h> #define BLK_SIZE 512 #define NAT_FAT_FREE 0 #define NAT_FAT_EOF (-1) #define NAT_FAT_SKIP (-2) #define NAT_FAT_BAD (-3) #define NAT_NAME_MAX 27 #define NAT_FILE_SIZE_MAX (0x7fffffff) #define NAT_DIR_SIZE_MAX (0x00100000) #define NAT_D_PER_BLOCK (BLK_SIZE / sizeof(struct nat_dirent)) #define ICHECK_MAX 16 static struct _mtab * mount; static char * dev_name; static int dev_fd; static unsigned icheck[ICHECK_MAX]; static int icheck_cnt; static int enable_write; static int show_names; static int qflag; static int sflag; static int fix; static uint8_t * rbam; static struct nat_super sb; static struct file { struct nat_header hd; uint32_t first_block; uint32_t true_nlink; int checked; } *file; static int file_count; static void load_super(void); static struct file * load_hdr(uint32_t first_block); static void save_hdr(struct file *file); static uint32_t check_bmap(struct file *file); static void check_file(unsigned first_block, int depth, char *name); static void check_dir(unsigned first_block, int depth, char *name); static void check_nlink(void); static void check_bam(void); static void find_mount(void); static void exit_fsck(int status); static int blk_in_range(uint32_t bn) { if (bn < sb.data_block) return 0; if (bn >= sb.data_block + sb.data_size) return 0; return 1; } static void bused(uint32_t bn) { rbam[bn / 8] |= 1 << (bn & 7); } static int bdupref(uint32_t bn) { if ((rbam[bn / 8] >> (bn & 7)) & 1) return 1; bused(bn); return 0; } static void load_super(void) { size_t bdai, edai; uint32_t edata; size_t rbamsz; lseek(dev_fd, BLK_SIZE, SEEK_SET); errno = EINVAL; if (read(dev_fd, &sb, sizeof sb) != sizeof sb) { warn("reading superblock"); exit_fsck(errno); } if (memcmp(sb.magic, NAT_MAGIC, sizeof NAT_MAGIC)) { warnx("superblock: bad magic"); if (fix) { memcpy(sb.magic, "OS386FS", 8); lseek(dev_fd, BLK_SIZE, SEEK_SET); if (write(dev_fd, &sb, sizeof sb) != sizeof sb) { warn("writing superblock"); exit_fsck(errno); } warnx("fixed"); } else exit_fsck(255); } rbamsz = sb.bam_size * BLK_SIZE; rbam = calloc(rbamsz, 1); if (!rbam) { warn("malloc"); exit_fsck(errno); } edata = sb.data_block + sb.data_size; bdai = sb.data_block / 8; edai = edata / 8; if (bdai >= rbamsz || edai > rbamsz) { warnx("bdai = %u, edai = %u, rbamsz = %u", bdai, edai, rbamsz); warnx("superblock inconsistent"); exit_fsck(255); } memset(rbam, 255, bdai); memset(rbam + edai, 255, rbamsz - edai); if (sb.data_block & 7) rbam[bdai] = 255 >> (8 - (sb.data_block & 7)); if (edata & 7) rbam[edai] = ~(255 >> (8 - (edata & 7))); } static void mark_clean(void) { sb.dirty = 0; lseek(dev_fd, BLK_SIZE, SEEK_SET); if (write(dev_fd, &sb, sizeof sb) != sizeof sb) { warn("writing superblock"); exit_fsck(errno); } warnx("filesystem marked clean"); } static struct file *load_hdr(uint32_t first_block) { int cnt; int i; for (i = 0; i < file_count; i++) if (file[i].first_block == first_block) return &file[i]; file_count++; file = realloc(file, file_count * sizeof(struct file)); if (!file) { warn("realloc"); exit_fsck(errno); } lseek(dev_fd, first_block * BLK_SIZE, SEEK_SET); cnt = read(dev_fd, &file[file_count - 1].hd, sizeof(struct nat_header)); if (cnt < 0) { warn("reading header of %i", first_block); exit_fsck(errno); } file[file_count - 1].first_block = first_block; file[file_count - 1].true_nlink = 0; file[file_count - 1].checked = 0; return &file[file_count - 1]; } static void save_hdr(struct file *file) { lseek(dev_fd, file->first_block * BLK_SIZE, SEEK_SET); if (write(dev_fd, &file->hd, sizeof file->hd) != sizeof file->hd) { warn("writing header of %i", file->first_block); exit_fsck(errno); } } static uint32_t check_imap(uint32_t mbn, int indl) { uint32_t imap[BLK_SIZE / 4]; uint32_t bcnt = 0; uint32_t bn; int dirty; int i; lseek(dev_fd, mbn * BLK_SIZE, SEEK_SET); if (read(dev_fd, imap, sizeof imap) < 0) { warn("reading block %i", (int)mbn); exit_fsck(errno); } for (i = 0; i < BLK_SIZE / 4; i++) { bn = imap[i]; if (!bn) continue; if (!blk_in_range(bn)) { warnx("incorrect bn %lu in level %i map %lu", (unsigned long)bn, indl, (unsigned long)mbn); if (fix) { imap[i] = 0; dirty = 1; warnx("punched a hole"); continue; } } if (bdupref(bn)) { warnx("block %lu in level %i map %lu is referenced elsewhere", (unsigned long)bn, indl, (unsigned long)file->first_block); if (fix) { imap[i] = 0; warnx("punched a hole"); } dirty = 1; continue; } bcnt++; if (!indl) continue; bcnt += check_imap(bn, indl - 1); } if (dirty) { lseek(dev_fd, mbn * BLK_SIZE, SEEK_SET); if (write(dev_fd, imap, sizeof imap) < 0) { warn("writing block %i", (int)mbn); exit_fsck(errno); } } return bcnt; } static uint32_t check_bmap(struct file *file) { uint32_t bcnt = 1; uint32_t bn; int i; for (i = 0; i < sizeof file->hd.bmap / 4; i++) { bn = file->hd.bmap[i]; if (!bn) continue; if (!blk_in_range(bn)) { warnx("incorrect bn %lu in file %lu", (unsigned long)bn, (unsigned long)file->first_block); if (fix) { file->hd.bmap[i] = 0; warnx("punched a hole"); save_hdr(file); continue; } } if (bdupref(bn)) { warnx("block %lu in file %lu is referenced elsewhere", (unsigned long)bn, (unsigned long)file->first_block); if (fix) { file->hd.bmap[i] = 0; save_hdr(file); warnx("punched a hole"); } continue; } bcnt++; if (i < file->hd.ndirblks) continue; bcnt += check_imap(bn, file->hd.nindirlev - 1); } return bcnt; } static void check_file(unsigned first_block, int depth, char *name) { struct file *file; uint32_t size; int i; if (show_names) { for (i = 0; i < depth; i++) fputc(' ', stderr); fprintf(stderr, "%s (%i)\n", name, first_block); } for (i = 0; i < icheck_cnt; i++) if (icheck[i] == first_block) { for (i = 0; i < depth; i++) fputc(' ', stderr); fprintf(stderr, "%s (%i)\n", name, first_block); } file = load_hdr(first_block); file->true_nlink++; if (file->checked) return; file->checked = 1; if (file->hd.nindirlev < 1 || file->hd.nindirlev > 8) { warnx("%lu bad block map indirection level %i -- cannot fix", first_block, (int)file->hd.nindirlev); return; } if (bdupref(first_block)) { warnx("%lu shared with a data block -- cannot fix", first_block); return; } switch (file->hd.mode & 070000) { case 030000: check_dir(first_block, depth, name); file = load_hdr(first_block); return; case 040000: case 020000: case 010000: return; case 0: break; default: warnx("%li has incorrect file type in mode field", (long)first_block); if (fix) { file->hd.mode &= ~070000; save_hdr(file); warnx("converted to regular file"); break; } /* return; */ } size = check_bmap(file); if (file->hd.blocks != size) { warnx("%li has incorrect block count (is %i, should be %i)", (long)first_block, file->hd.blocks, size); if (fix) { file->hd.blocks = size; save_hdr(file); warnx("fixed"); } } } static uint32_t bmap(struct file *f, uint32_t log) { uint32_t imap[128]; uint32_t bn; uint32_t i; int shift; if (log < f->hd.ndirblks) { if (log >= sizeof f->hd.bmap / sizeof *f->hd.bmap) goto too_big; return f->hd.bmap[log]; } shift = 7 * f->hd.nindirlev; i = f->hd.ndirblks + (log >> shift); if (i >= sizeof f->hd.bmap / sizeof *f->hd.bmap) goto too_big; bn = f->hd.bmap[i]; shift -= 7; while (bn && shift >= 0) { lseek(dev_fd, bn * BLK_SIZE, SEEK_SET); if (read(dev_fd, imap, sizeof imap) < 0) { warnx("error reading block %lu", (unsigned long)bn); exit_fsck(errno); } bn = imap[(bn >> shift) & 127]; shift -= 7; } return bn; too_big: warnx("log bn %lu too big, file %lu", (unsigned long)log, (unsigned long)file->first_block); exit_fsck(errno); return 0; } static void check_dir(unsigned first_block, int depth, char *name) { struct nat_dirent dir[NAT_D_PER_BLOCK]; struct file *file; uint32_t log, phys, cnt; uint32_t size; file = load_hdr(first_block); size = check_bmap(file); if (file->hd.blocks != size) { warnx("%li has incorrect block count", (long)first_block); if (fix) { file->hd.blocks = size; save_hdr(file); warnx("fixed"); } } cnt = (file->hd.size + BLK_SIZE - 1) / BLK_SIZE; for (log = 0; log < cnt; log++) { int i; phys = bmap(file, log); if (!phys) continue; lseek(dev_fd, phys * BLK_SIZE, SEEK_SET); errno = EINVAL; if (read(dev_fd, &dir, sizeof dir) != sizeof dir) { warn("reading directory"); exit_fsck(errno); } for (i = 0; i < NAT_D_PER_BLOCK; i++) { if (!dir[i].first_block) continue; if (dir[i].name[NAT_NAME_MAX]) { warnx("directory entry name too long"); if (fix) { dir[i].name[NAT_NAME_MAX] = 0; lseek(dev_fd, phys * BLK_SIZE, SEEK_SET); if (write(dev_fd, &dir, sizeof dir) < 0) { warn("writing directory"); exit_fsck(errno); } warnx("name truncated"); } } if (strchr(dir[i].name, '/')) { char *p; warnx("slash character in file name"); if (fix) { while ((p = strchr(dir[i].name, '/'))) *p = '_'; lseek(dev_fd, phys * BLK_SIZE, SEEK_SET); if (write(dev_fd, &dir, sizeof dir) < 0) { warn("writing directory"); exit_fsck(errno); } warnx("replaced with underscore"); } } if (!*dir[i].name) { warnx("directory entry with no name"); if (fix) { memset(dir[i].name, 0, sizeof dir[i].name); lseek(dev_fd, phys * BLK_SIZE, SEEK_SET); if (write(dev_fd, &dir, sizeof dir) < 0) { warn("writing directory"); exit_fsck(errno); } warnx("cleared"); } continue; } if (dir[i].first_block < sb.data_block || dir[i].first_block >= sb.data_block + sb.data_size) { warnx("directory entry has bad first_block member"); if (fix) { memset(dir[i].name, 0, sizeof dir[i].name); lseek(dev_fd, phys * BLK_SIZE, SEEK_SET); errno = EINVAL; if (write(dev_fd, &dir, sizeof dir) < 0) { warn("writing directory"); exit_fsck(errno); } warnx("cleared"); } continue; } check_file(dir[i].first_block, depth + 1, dir[i].name); file = load_hdr(first_block); } } } static void check_nlink(void) { int i; for (i = 0; i < file_count; i++) if (file[i].true_nlink != file[i].hd.nlink) { warnx("%li has incorrect link count", (long)file[i].first_block); if (fix) { file[i].hd.nlink = file[i].true_nlink; save_hdr(&file[i]); warnx("fixed"); } } } static void comp_bam(uint8_t *rbam, uint8_t *dbam, uint32_t bbn) { uint32_t dbn; uint8_t xor; int i, n; for (i = 0; i < BLK_SIZE; i++) { if (rbam[i] == dbam[i]) continue; xor = rbam[i] ^ dbam[i]; n = 0; while (xor) { if (xor & 1) { dbn = bbn * BLK_SIZE * 8; dbn |= i * 8; dbn |= n; if ((dbam[i] >> n) & 1) warnx("block %lu is marked as used", (unsigned long)dbn); else warnx("block %lu is not marked as used", (unsigned long)dbn); } xor >>= 1; n++; } } } static void check_bam(void) { uint8_t dbam[BLK_SIZE]; uint8_t *p; uint32_t i; int bad = 0; lseek(dev_fd, sb.bam_block * BLK_SIZE, SEEK_SET); p = rbam; for (i = 0; i < sb.bam_size; i++) { if (read(dev_fd, dbam, sizeof dbam) < 0) { warn("reading BAM"); exit_fsck(255); } if (memcmp(p, dbam, sizeof dbam)) { if (fix) { lseek(dev_fd, (sb.bam_block + i) * BLK_SIZE, SEEK_SET); if (write(dev_fd, p, sizeof dbam) < 0) { warnx("bad BAM"); warn("writing BAM"); exit_fsck(255); } } if (show_names) comp_bam(p, dbam, i); bad = 1; } p += sizeof dbam; } if (bad) { warnx("bad BAM"); if (fix) warnx("fixed"); } } static void find_mount(void) { static struct _mtab m[MOUNT_MAX]; int i; if (_mtab(m, sizeof m)) err(errno, "_mtab"); for (i = 0; i < MOUNT_MAX; i++) if (m[i].mounted && !strcmp(m[i].device, dev_name)) { mount = &m[i]; return; } } static void find_root(void) { static struct _mtab m[MOUNT_MAX]; int i; if (_mtab(m, sizeof m)) err(errno, "_mtab"); for (i = 0; i < MOUNT_MAX; i++) if (m[i].mounted && !*m[i].prefix) { if (!strcmp(m[i].fstype, "boot")) { if (!qflag) errx(0, "not checking"); exit(0); } if (strcmp(m[i].fstype, "native")) errx(1, "not a native fs"); dev_name = m[i].device; mount = &m[i]; return; } errx(1, "root not mounted"); } static void exit_fsck(int status) { if (mount) _mount(mount->prefix, mount->device, mount->fstype, mount->flags); exit(status); } static void procopt(int argc, char **argv) { int opt; while (opt = getopt(argc, argv, "Fvwqrs"), opt > 0) switch (opt) { case 'F': fix = 1; break; case 'v': show_names = 1; break; case 'q': qflag = 1; break; case 'w': enable_write = 1; break; case 's': sflag = 1; break; default: exit(255); } } static void sig_int(int nr) { if (mount) _mount(mount->prefix, mount->device, mount->fstype, mount->flags); signal(nr, SIG_DFL); raise(nr); } int main(int argc, char **argv) { int i; if (argc == 2 && !strcmp(argv[1], "--help")) { fprintf(stderr, "Usage: fsck [OPTIONS] [--] DEVICE [INODE]...\n\n" "Check and repair filesystem.\n\n" " -F try to repair the filesystem\n" " -v be verbose\n" " -q quiet mode\n" " -w remount the filesystem read/write after successfull check\n\n" "Default is not to modify the filesystem even if errors are detected.\n\n" "The filesystem is not accessible during a check.\n\n"); return 0; } procopt(argc, argv); if (chdir("/dev")) err(errno, "/dev"); if (optind < argc) dev_name = argv[optind++]; else find_root(); dev_fd = open(dev_name, O_RDWR); if (dev_fd < 0) err(errno, "%s", dev_name); for (i = optind; i < argc; i++) { if (icheck_cnt >= ICHECK_MAX) { errx(255, "to many i-nodes requested"); return 255; } icheck[icheck_cnt++] = atol(argv[i]); } find_mount(); signal(SIGQUIT, sig_int); signal(SIGINT, sig_int); if (mount && _umount(mount->prefix)) err(errno, "_umount"); if (!qflag) warnx("loading superblock"); load_super(); if (sflag) { if (sb.dirty) warnx("filesystem is not clean -- checking"); else { if (!qflag) warnx("filesystem is clean -- not checking"); goto fini; } } if (!qflag) warnx("checking files and directories"); check_file(sb.root_block, 0, "/"); if (!qflag) warnx("checking link counts"); check_nlink(); if (!qflag) warnx("checking BAM for orphaned blocks"); check_bam(); if (!qflag) warnx("%i files checked", file_count); if (fix && sb.dirty) mark_clean(); fini: if (mount && enable_write) mount->flags &= ~MF_READ_ONLY; if (mount) _mount(mount->prefix, mount->device, mount->fstype, mount->flags); return 0; }
19.845252
105
0.614603
9ffc3011409bcef4f6ab9c01318d7d99c5d0f706
22,134
c
C
src/parmt.c
bakerb845/parmt
2b4097df02ef5e56407d40e821d5c7155c2e4416
[ "Intel" ]
null
null
null
src/parmt.c
bakerb845/parmt
2b4097df02ef5e56407d40e821d5c7155c2e4416
[ "Intel" ]
null
null
null
src/parmt.c
bakerb845/parmt
2b4097df02ef5e56407d40e821d5c7155c2e4416
[ "Intel" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <limits.h> #include <omp.h> #include <stdbool.h> #include <getopt.h> #include <math.h> #include <mpi.h> #include "parmt_config.h" #ifdef PARMT_USE_INTEL #include <ippcore.h> #include <mkl.h> #include <mkl_cblas.h> #else #include <cblas.h> #endif #include "compearth.h" #include "parmt_mtsearch.h" #include "parmt_postProcess.h" #include "parmt_utils.h" #include "iscl/array/array.h" #include "iscl/memory/memory.h" #define PROGRAM_NAME "parmt" static int parseArguments(int argc, char *argv[], const int nprocs, int *npInObsGroups, int *npInLocGroups, int *npInMTGroups, char iniFile[PATH_MAX]); static void printUsage(void); int parmt_freeData(struct parmtData_struct *data); int parmt_freeLocalMTs(struct localMT_struct *mts); /*! * */ int main(int argc, char *argv[]) { char iniFile[PATH_MAX]; double *betas, *h, *kappas, *gammas, *M0s, *sigmas, *thetas, *u, *v; double *deps, *luneMPDF, *phi, t0, t1, du, dv, dh, dk, ds; int64_t ngridSearch; double hLower, hUpper, uLower, uUpper, vLower, vUpper, xnorm; int *lags, i, ierr, iobs, myid, npInLocGroups, nmt, npInMTGroups, npInObsGroups, nprocs, provided; int ix, iy, k; MPI_Comm mtComm, locComm, obsComm; bool linMTComm, linLocComm, linObsComm; const int master = 0; const int ldm = 8; struct parmtGeneralParms_struct parms; struct parmtData_struct data; struct parmtMtSearchParms_struct mtsearch; struct localMT_struct mtloc; //------------------------------------------------------------------------// // // initialize MPI, ISCL, and handle threading issues MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided); MPI_Comm_rank(MPI_COMM_WORLD, &myid); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); iscl_init(); #ifdef PARMT_USE_INTEL //omp_set_num_threads(2); mkl_set_num_threads(1); ippSetNumThreads(1); #endif // initialize phi = NULL; M0s = NULL; betas = NULL; gammas = NULL; sigmas = NULL; kappas = NULL; thetas = NULL; h = NULL; u = NULL; v = NULL; lags = NULL; memset(&parms, 0, sizeof(struct parmtGeneralParms_struct)); memset(&data, 0, sizeof(struct parmtData_struct)); memset(&mtsearch, 0, sizeof(struct parmtMtSearchParms_struct)); memset(&mtloc, 0, sizeof(struct localMT_struct)); if (myid == master) { ierr = parseArguments(argc, argv, nprocs, &npInObsGroups, &npInLocGroups, &npInMTGroups, iniFile); if (ierr != 0){goto INIT_ERROR;} // read the ini file printf("%s: Parsing ini file %s...\n", PROGRAM_NAME, iniFile); ierr = 0; ierr += parmt_utils_readGeneralParms(iniFile, &parms); strcpy(parms.programName, PROGRAM_NAME); parms.programID = PARMT_ID; ierr += parmt_utils_readMtSearch(iniFile, &mtsearch); if (ierr != 0) { printf("%s: Error reading ini file\n", PROGRAM_NAME); goto INIT_ERROR; } printf("%s: Process management:\n", PROGRAM_NAME); printf(" Number of processes in observation groups %d\n", npInObsGroups); printf(" Number of processes in location groups %d\n", npInLocGroups); printf(" Number of processes in moment tensor groups %d\n", npInMTGroups); // npInObsGroups = 1; // npInLocGroups = 1; // npInMTGroups = nprocs; printf("verify greens fns are correct\n"); /* double pAxis[3], nAxis[3], tAxis[3], beta, gamma, u,v; u= 3.0*M_PI/8.0; v=-1.0/9.0; compearth_u2beta(1, 10, 2, &u, 1.e-10, &beta); compearth_v2gamma(1, &v, &gamma); postprocess_tt2tnp(beta, gamma, 4.0*M_PI/5.0, -M_PI/2.0, 0.723, pAxis, nAxis, tAxis); int nxp = 51; double *xw1 = memory_calloc64f(nxp*nxp); double *yw1 = memory_calloc64f(nxp*nxp); int8_t *pn1 = (int8_t *) calloc(nxp*nxp, sizeof(int8_t)); const double xc = 1.5; const double yc = 1.5; const double rad = 1.0; // Compute the corresponding moment tensor double M0loc = 1.0/sqrt(2.0), Muse[6], lamUse[9], Uuse[9]; double gammaDeg = gamma*180.0/M_PI; double deltaDeg = (M_PI_2 - beta)*180.0/M_PI; double kappaDeg = (4.0*M_PI/5.0)*180.0/M_PI; double sigmaDeg = (-M_PI_2)*180.0/M_PI; double thetaDeg = 0.723*180.0/M_PI; compearth_tt2cmt(gammaDeg, deltaDeg, M0loc, kappaDeg, thetaDeg, sigmaDeg, Muse, lamUse, Uuse); printf("mt = [%f,%f,%f,%f,%f,%f]\n", Muse[0], Muse[1], Muse[2], Muse[3], Muse[4], Muse[5]); printf("drawing\n"); for (int i=0; i<10000; i++) { postprocess_tnp2beachballPolarity(nxp, xc, yc, rad, pAxis, nAxis, tAxis, xw1, yw1, pn1); } FILE *fwork = fopen("depmag/beachball.txt", "w"); for (int iy=0; iy<nxp; iy++) { for (int ix=0; ix<nxp; ix++) { int k = iy*nxp + ix; fprintf(fwork, "%e %e %d\n", xw1[k], yw1[k], pn1[k]); } fprintf(fwork, "\n"); } fclose(fwork); memory_free64f(&xw1); memory_free64f(&yw1); free(pn1); printf("back\n"); //getchar(); */ } INIT_ERROR:; MPI_Bcast(&ierr, 1, MPI_INT, master, MPI_COMM_WORLD); if (ierr != 0){goto FINISH;} MPI_Bcast(&npInObsGroups, 1, MPI_INT, master, MPI_COMM_WORLD); MPI_Bcast(&npInLocGroups, 1, MPI_INT, master, MPI_COMM_WORLD); MPI_Bcast(&npInMTGroups, 1, MPI_INT, master, MPI_COMM_WORLD); // split the communicators ierr = parmt_splitComm(MPI_COMM_WORLD, npInObsGroups, npInLocGroups, npInMTGroups, &linObsComm, &obsComm, &linLocComm, &locComm, &linMTComm, &mtComm); if (ierr != 0) { printf("%s: Fatal error splitting communicators - have a nice day\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } // load the observations and greens functions then broadcast if (myid == master) { printf("%s: Loading data...\n", PROGRAM_NAME); memset(&data, 0, sizeof(struct parmtData_struct)); ierr = utils_dataArchive_readAllWaveforms(parms.dataFile, &data); data.est = (struct sacData_struct *) calloc((size_t) data.nobs, sizeof(struct sacData_struct)); ngridSearch = (int64_t) (mtsearch.nm*mtsearch.nb*mtsearch.ng) *(int64_t) (mtsearch.nk*mtsearch.ns*mtsearch.nt) *(int64_t) data.nlocs; if (ngridSearch > INT_MAX) { printf("%s: Error - grid search too big - integer overflow", PROGRAM_NAME); ierr = 1; } } MPI_Bcast(&ierr, 1, MPI_INT, master, MPI_COMM_WORLD); if (ierr != 0){goto FINISH;} // Send the inputs to everyone if (myid == master) { printf("%s: Broadcasting parameters...\n", PROGRAM_NAME); } ierr = parmt_broadcast_mtSearchParms(&mtsearch, master, MPI_COMM_WORLD); if (ierr != 0) { printf("%s: Fatal error broadcasting parameters\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } ierr = parmt_broadcast_generalParms(&parms, master, MPI_COMM_WORLD); if (ierr != 0) { printf("%s: Fatal error broadcasting general parameters\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } // Send the waveforms to everyone ierr = parmt_broadcast_data(&data, master, MPI_COMM_WORLD); if (ierr != 0) { printf("%s: Fatal error broadcasting waveforms\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } // Discretize the moment tensor space in (u, v, h) space if (myid == master) { printf("%s: Discretizing MT space...\n", PROGRAM_NAME); } // Discretize the moment tensor space in (u, v, h) space ierr = parmt_discretizeCells64f( mtsearch.nb, mtsearch.betaLower, mtsearch.betaUpper, mtsearch.ng, mtsearch.gammaLower, mtsearch.gammaUpper, mtsearch.nk, mtsearch.kappaLower, mtsearch.kappaUpper, mtsearch.ns, mtsearch.sigmaLower, mtsearch.sigmaUpper, mtsearch.nt, mtsearch.thetaLower, mtsearch.thetaUpper, mtsearch.nm, mtsearch.m0Lower, mtsearch.m0Upper, mtsearch.luseLog, &betas, &gammas, &kappas, &sigmas, &thetas, &M0s); if (ierr != 0) { printf("%s: Error discretizing MT space\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } /* compearth_beta2u(1, &mtsearch.betaLower, &uLower); compearth_beta2u(1, &mtsearch.betaUpper, &uUpper); compearth_gamma2v(1, &mtsearch.gammaLower, &vLower); compearth_gamma2v(1, &mtsearch.gammaUpper, &vUpper); compearth_theta2h(1, &mtsearch.thetaLower, &hLower); compearth_theta2h(1, &mtsearch.thetaUpper, &hUpper); du = (uUpper - uLower)/(double) mtsearch.nb; dv = (vUpper - vLower)/(double) mtsearch.ng; dh =-(hUpper - hLower)/(double) mtsearch.nt; dk = (mtsearch.kappaUpper - mtsearch.kappaLower)/(double) mtsearch.nk; ds = (mtsearch.sigmaUpper - mtsearch.sigmaLower)/(double) mtsearch.ns; //if (myid == master){printf("%f %f %f\n", du, dv, dh);} u = array_linspace64f(uLower+du/2, uUpper-du/2, mtsearch.nb, &ierr); v = array_linspace64f(vLower+dv/2, vUpper-dv/2, mtsearch.ng, &ierr); h = array_linspace64f(hLower-dh/2, hUpper+dh/2, mtsearch.nt, &ierr); betas = memory_calloc64f(mtsearch.nb); gammas = memory_calloc64f(mtsearch.ng); thetas = memory_calloc64f(mtsearch.nt); compearth_u2beta(mtsearch.nb, 20, 2, u, 1.e-6, betas); compearth_v2gamma(mtsearch.ng, v, gammas); compearth_h2theta(mtsearch.nt, h, thetas); M0s = array_linspace64f(mtsearch.m0Lower, mtsearch.m0Upper, mtsearch.nm, &ierr); kappas = array_linspace64f(mtsearch.kappaLower+dk/2, mtsearch.kappaUpper-dk/2, mtsearch.nk, &ierr); sigmas = array_linspace64f(mtsearch.sigmaLower+ds/2, mtsearch.sigmaUpper-ds/2, mtsearch.ns, &ierr); */ //if (myid != master){for (int i=0; i<mtsearch.nb; i++){printf("%f %f\n", u[i],betas[i]);}} // avoid an annoying warning for (i=0; i<mtsearch.ns; i++) { if (fabs(sigmas[i]) < 1.e-7){sigmas[i] = 1.e-7;} } nmt = mtsearch.ng*mtsearch.nb*mtsearch.nk *mtsearch.ns*mtsearch.nt*mtsearch.nm; if (myid == master) { printf("%s: Discretizing moment tensor...\n", PROGRAM_NAME); } t0 = MPI_Wtime(); ierr = parmt_discretizeMT64f_MPI(mtComm, mtsearch.ng, gammas, mtsearch.nb, betas, mtsearch.nm, M0s, mtsearch.nk, kappas, mtsearch.nt, thetas, mtsearch.ns, sigmas, ldm, &mtloc); if (ierr != 0) { printf("%s: Error discretizing moment tensor on process %d\n", PROGRAM_NAME, myid); MPI_Abort(MPI_COMM_WORLD, 30); } MPI_Barrier(MPI_COMM_WORLD); t1 = MPI_Wtime(); if (myid == master) { printf("%s: Discretization time %6.2f (seconds)\n", PROGRAM_NAME, t1 - t0); } // Initialize the output file t0 = MPI_Wtime(); if (myid == master) { printf("%s: Initializing output file...\n", PROGRAM_NAME); deps = memory_calloc64f(data.nlocs); for (i=0; i<data.nlocs; i++) { deps[i] = data.sacGxx[i].header.evdp; } ierr = parmt_io_createObjfnArchive64f(//parms.resultsDir, parms.projnm, //parms.resultsFileSuffix, PROGRAM_NAME, parms.parmtArchive, data.nobs, data.nlocs, deps, mtsearch.nm, M0s, mtsearch.nb, betas, mtsearch.ng, gammas, mtsearch.nk, kappas, mtsearch.ns, sigmas, mtsearch.nt, thetas); memory_free64f(&deps); } MPI_Barrier(MPI_COMM_WORLD); // Compute the objective functions t0 = MPI_Wtime(); phi = NULL; lags = NULL; /* nlags = 0; double lagTime; bool ldefault, lwantLags; int iobs = 0; int nlags = 0; phi = NULL; lags = NULL; nlags = 0; if (parms.lwantLags) { //lagTime = data.data[iobs].header.user0; //if (lagTime < 0.0){lagTime = parms.defaultMaxLagTime;} lagTime = parmt_utils_getLagTime(data.data[iobs], parms.defaultMaxLagTime, &ldefault); nlags = (int) (lagTime/data.data[iobs].header.delta + 0.5); } lags = NULL; lwantLags = false; if (nlags > 0){lwantLags = true;} */ if (myid == master) { phi = memory_calloc64f(data.nlocs*mtloc.nmtAll); } else { phi = memory_calloc64f(1); } // Perform the grid search MPI_Wtime(); ierr = parmt_obsSearch64f(MPI_COMM_WORLD, obsComm, locComm, linObsComm, linLocComm, parms, data, mtloc, phi); if (ierr != 0) { printf("%s: Error calling obsSearch64f\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } MPI_Barrier(MPI_COMM_WORLD); if (myid == master) { MPI_Wtime(); printf("%s: Objective function computation time: %f\n", PROGRAM_NAME, MPI_Wtime() - t0); } if (ierr != 0) { printf("%s: Error calling locSearchXC64f\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } if (myid == master) { printf("%s: Writing results...\n", PROGRAM_NAME); ierr = parmt_io_writeObjectiveFunction64f( //parms.resultsDir, parms.projnm, parms.resultsFileSuffix, parms.parmtArchive, nmt, phi); if (ierr != 0) { printf("%s: Error writing objective function\n", PROGRAM_NAME); goto FINISH; } int jloc, jm, jb, jg, jk, js, jt; int imtopt = array_argmax64f(data.nlocs*mtloc.nmtAll, phi, &ierr); marginal_getOptimum(data.nlocs, mtsearch.nm, mtsearch.nb, mtsearch.ng, mtsearch.nk, mtsearch.ns, mtsearch.nt, phi, &jloc, &jm, &jb, &jg, &jk, &js, &jt); printf("%d %f %f %f %f %f %f\n", jloc, gammas[jg]*180.0/M_PI, 90.0-betas[jb]*180.0/M_PI, 1.0, kappas[jk]*180.0/M_PI, thetas[jt]*180.0/M_PI, sigmas[js]*180.0/M_PI); double Muse[6], Mned[6], lam[3], U[9]; printf("phi opt: %d %e\n", imtopt, phi[imtopt]); printf("%d %d %d %d %d %d %d\n", jloc, jg, jb, jm, jk, jt, js); double gammaOpt = gammas[jg]*180.0/M_PI; double deltaOpt = 90.0-betas[jb]*180.0/M_PI; double kappaOpt = kappas[jk]*180.0/M_PI; double thetaOpt = thetas[jt]*180.0/M_PI; double sigmaOpt = sigmas[js]*180.0/M_PI; compearth_TT2CMT(1, &gammaOpt, &deltaOpt, &M0s[jm], &kappaOpt, &thetaOpt, &sigmaOpt, Muse, lam, U); /* compearth_tt2cmt(gammas[jg]*180.0/M_PI, 90.0-betas[jb]*180.0/M_PI, M0s[jm], kappas[jk]*180.0/M_PI, thetas[jt]*180.0/M_PI, sigmas[js]*180.0/M_PI, Muse, lam, U); */ parmt_discretizeMT64f(1, &gammas[jg], 1, &betas[jb], 1, &M0s[jm], 1, &kappas[jk], 1, &thetas[jt], 1, &sigmas[js], 6, 1, Mned); //printf("%e %e %e\n", phi[0], phi[1000], phi[500000]); printf("mtUSE =[%f,%f,%f,%f,%f,%f]\n", Muse[0], Muse[1], Muse[2], Muse[3], Muse[4], Muse[5]); printf("mtNED =[%f,%f,%f,%f,%f,%f]\n", Mned[0], Mned[1], Mned[2], Mned[3], Mned[4], Mned[5]); } FINISH:; if (linObsComm){MPI_Comm_free(&obsComm);} if (linLocComm){MPI_Comm_free(&locComm);} if (linMTComm){MPI_Comm_free(&mtComm);} memory_free64f(&M0s); memory_free64f(&h); memory_free64f(&u); memory_free64f(&v); memory_free64f(&betas); memory_free64f(&gammas); memory_free64f(&kappas); memory_free64f(&sigmas); memory_free64f(&thetas); memory_free64f(&phi); memory_free32i(&lags); parmt_freeData(&data); parmt_freeLocalMTs(&mtloc); iscl_finalize(); MPI_Finalize(); return EXIT_SUCCESS; } static int parseArguments(int argc, char *argv[], const int nprocs, int *npInObsGroups, int *npInLocGroups, int *npInMTGroups, char iniFile[PATH_MAX]) { bool linFile; int prod; linFile = false; *npInObsGroups = 1; *npInLocGroups = 1; *npInMTGroups = 1; memset(iniFile, 0, PATH_MAX*sizeof(char)); while (true) { static struct option longOptions[] = { {"help", no_argument, 0, '?'}, {"help", no_argument, 0, 'h'}, {"ini_file", required_argument, 0, 'i'}, {"obsGroupSize", required_argument, 0, 'w'}, {"mtGroupSize", required_argument, 0, 'm'}, {"locGroupSize", required_argument, 0, 'l'}, {0, 0, 0, 0} }; int c, optionIndex; c = getopt_long(argc, argv, "?hi:w:m:l:", longOptions, &optionIndex); if (c ==-1){break;} if (c == 'i') { strcpy(iniFile, (const char *) optarg); linFile = true; } else if (c == 'w' && nprocs > 1) { *npInObsGroups = atoi(optarg); } else if (c == 'l' && nprocs > 1) { *npInLocGroups = atoi(optarg); } else if (c == 'm' && nprocs > 1) { *npInMTGroups = atoi(optarg); } else if (c == 'h' || c == '?') { printUsage(); return -2; } else { printf("%s: Unknown options: %s\n", PROGRAM_NAME, argv[optionIndex]); } } if (!linFile) { printf("%s: Error must specify ini file\n\n", PROGRAM_NAME); printUsage(); return -1; } prod = (*npInObsGroups)*(*npInLocGroups)*(*npInMTGroups); if (prod != nprocs) { if (prod != 1) { printf("%s: Invalid process layout - defaulting to (%d,%d,%d)\n", PROGRAM_NAME, 1, 1, nprocs); } *npInObsGroups = 1; *npInLocGroups = 1; *npInMTGroups = nprocs; } return 0; } static void printUsage(void) { printf("Usage:\n parmt -i input_file\n\n"); printf("Required arguments:\n"); printf(" -i input_file specifies the initialization file\n"); printf("\n"); printf("Optional arguments:\n"); printf(" -m number of processes in moment-tensor groups\n"); printf(" -w number of processes in waveform (observation) groups\n"); printf(" -l number of processes in location groups\n"); printf(" -h displays this message\n"); printf(" Note if m*w*l must equal the number of processes\n"); printf(" If they are not set the program will set -m=nprocs\n"); return; } int parmt_freeData(struct parmtData_struct *data) { int i; if (data->nobs > 0 && data->nlocs > 0 && data->sacGxx != NULL && data->sacGyy != NULL && data->sacGzz != NULL && data->sacGxy != NULL && data->sacGxz != NULL && data->sacGyz != NULL) { for (i=0; i<data->nobs*data->nlocs; i++) { sacio_freeData(&data->sacGxx[i]); sacio_freeData(&data->sacGyy[i]); sacio_freeData(&data->sacGzz[i]); sacio_freeData(&data->sacGxy[i]); sacio_freeData(&data->sacGxz[i]); sacio_freeData(&data->sacGyz[i]); } free(data->sacGxx); free(data->sacGyy); free(data->sacGzz); free(data->sacGxy); free(data->sacGxz); free(data->sacGyz); } if (data->nobs > 0 && data->data != NULL) { for (i=0; i<data->nobs; i++) { sacio_freeData(&data->data[i]); } free(data->data); } if (data->nobs > 0 && data->est != NULL) { free(data->est); } memset(data, 0, sizeof(struct parmtData_struct)); return 0; } int parmt_freeLocalMTs(struct localMT_struct *mtloc) { memory_free64f(&mtloc->mts); //memory_free32i(&mtloc->l2g); // TODO remove memory_free32i(&mtloc->offset); memset(mtloc, 0, sizeof(struct localMT_struct)); return 0; }
35.990244
99
0.529864
bfdabea5db0938cbe0fa55991b3117820da24dc4
831
h
C
HDClassifyTable/HDClassifyTable/View/HDLeftTableHeaderView.h
Joyinter/HDClassifyTable
1b8c626604f588edaf2db74f8e5467b376153233
[ "MIT" ]
2
2017-02-13T01:22:08.000Z
2019-07-20T02:58:13.000Z
HDClassifyTable/HDClassifyTable/View/HDLeftTableHeaderView.h
Joyinter/HDClassifyTable
1b8c626604f588edaf2db74f8e5467b376153233
[ "MIT" ]
null
null
null
HDClassifyTable/HDClassifyTable/View/HDLeftTableHeaderView.h
Joyinter/HDClassifyTable
1b8c626604f588edaf2db74f8e5467b376153233
[ "MIT" ]
1
2018-10-09T01:08:06.000Z
2018-10-09T01:08:06.000Z
// // HDLeftTableHeaderView.h // HDClassifyTable // // Created by Joyinter on 2017/2/10. // Copyright © 2017年 Joyinter. All rights reserved. // #import <UIKit/UIKit.h> extern NSString * const kHDLeftTableHeaderViewIdentifier; extern NSString * const kHDLeftTableHeaderViewSetDeselectedNotification; @protocol HDLeftTableHeaderViewDelegate; @interface HDLeftTableHeaderView : UITableViewHeaderFooterView @property (nonatomic, weak) id <HDLeftTableHeaderViewDelegate> delegate; @property (nonatomic, assign) NSUInteger section; @property (nonatomic, assign) BOOL isSelected; - (void)configWithData:(NSDictionary *)data; @end @protocol HDLeftTableHeaderViewDelegate <NSObject> - (void)classifyListHeaderView:(HDLeftTableHeaderView *)classifyHeaderView isExpended:(BOOL)isExpended isUserTapped:(BOOL)isUserTapped; @end
25.181818
135
0.805054
bfe181ee53772270ca611de086670e6588f7b758
4,479
c
C
Greedy Method Implementation/TSP_greedy_method.c
shuvankarroy/Basic_Algorithm_C
d8a3615b18942f4f1e7a4624eef4cf2eb3d12ae8
[ "MIT" ]
null
null
null
Greedy Method Implementation/TSP_greedy_method.c
shuvankarroy/Basic_Algorithm_C
d8a3615b18942f4f1e7a4624eef4cf2eb3d12ae8
[ "MIT" ]
null
null
null
Greedy Method Implementation/TSP_greedy_method.c
shuvankarroy/Basic_Algorithm_C
d8a3615b18942f4f1e7a4624eef4cf2eb3d12ae8
[ "MIT" ]
null
null
null
// Implement Travelling Salesman Problem (TSP) problem using proper algorithm design technique. // Shuvankar Roy CSE/16/32 date : 19/11/2018 time : 12:12:10 #include <stdio.h> #include <stdlib.h> #define INF 9999 int e, nVertices, **graph,*visited,minCost,**t,startV; /*function prototype declaration*/ void input(); // Function for taking input from user void make_zero_visited(); // Function for resetting visited array void print_graph(); // print the user provided graph void TSP(int); // Function for Travelling salesman problem void printRes(); // Function to print the TSP solution int findNextVertex(int); // Function to find next vertex int main() { input(); print_graph(); TSP(startV); // call TSP() with starting node printRes(); // print the traversal path /*free up allocated memory*/ free(visited); free(graph); free(t); return 0; } void input(){ // taking input from user int i,j; printf("Enter number of vertices : "); scanf("%d",&nVertices); printf("Enter the start vertex for the TSP problem : "); scanf("%d",&startV); //dynamic memory allocation for graph and visited and t; visited = (int *)calloc(sizeof(int),nVertices+1); graph = (int **)calloc(sizeof(int),nVertices+1); for(i=0; i<=nVertices; i++){ graph[i] = (int *)calloc(sizeof(int),nVertices+1); } t = (int **)calloc(sizeof(int),nVertices+1); for(i=0;i<=nVertices;i++){ t[i] = (int *)calloc(sizeof(int),5); } printf("Enter the cost or weight matrix representation of the graph :\n"); printf("***Enter 0 in place of no connection***\n"); for(i=1; i<=nVertices; i++){ for(j=1; j<=nVertices; j++){ scanf("%d",&graph[i][j]); if(graph[i][j] == 0){ // set absent edges with INF graph[i][j] = INF; } } } } void print_graph(){ // print the cost matrix int i,j; printf("The cost matrix is :\n"); for(i=1; i<=nVertices; i++){ for(j=1; j<=nVertices; j++){ printf("%d\t",graph[i][j]); } printf("\n"); } } void TSP(int startVertex){ int i,j,minPath,minIndex,vertexCount = 1,currentVertex,nextVertex; make_zero_visited(); visited[startVertex] = 1; currentVertex = startVertex; while(vertexCount < nVertices){ // checking if all vertices are exhausted nextVertex = findNextVertex(currentVertex); // finding nearest vertex minPath = graph[currentVertex][nextVertex]; // distance of nextVertex if(minPath == INF){ // check if there exist any edge printf("Traversal Is not possible\n"); exit(0); } minCost += minPath; // update total traversal distance visited[nextVertex] = 1; // update visited array // updating t matrix t[vertexCount][1] = currentVertex; t[vertexCount][2] = nextVertex; t[vertexCount][3] = minPath; t[vertexCount][4] = minCost; currentVertex = nextVertex; vertexCount++; } if(graph[currentVertex][startVertex] < INF){ // checking if there exist any edge from last to initial node minPath = graph[currentVertex][startVertex]; minCost += minPath; visited[currentVertex] = 1; // updating t matrix t[vertexCount][1] = currentVertex; t[vertexCount][2] = startVertex; t[vertexCount][3] = minPath; t[vertexCount][4] = minCost; } else{ // traversal not possible printf("Traversal Is not possible\n"); exit(0); } } int findNextVertex(int row){ // finding the next vertex to visit by row int i; int minDistance = INF; int minIndex = 1; for(i=1; i<=nVertices; i++){ if(graph[row][i] < minDistance && visited[i]==0){ // check for unvisited minimum distant node minIndex = i; minDistance = graph[row][i]; } } return minIndex; // return the nearest unvisited node } void make_zero_visited(){ // reset the visited[1:nVertices] array int i; for(i=0; i<=nVertices; i++){ visited[i] = 0; } } void printRes(){ // print the traversal result int i; printf("\nMinimum cost for TSP problem is : %d",minCost); printf("\nOptimum Path for traversal is : \n"); for(i=1; i<=nVertices;i++){ if(i == 1) printf("--> V%d ",t[i][1]); printf("--> V%d ",t[i][2]); } printf("\nThe t matrix (distance in between vertices) is : \n"); printf("source \t destination \t min \t mincost\n"); for(i=1; i<=nVertices; i++){ printf("%d \t\t %d \t %d \t %d",t[i][1],t[i][2],t[i][3],t[i][4]); printf("\n"); } }
29.084416
96
0.62313
0f8e82d8a1ddbb3e5cddbab0ff1643d01eb3c915
5,984
c
C
runtime/examples/dtasmtime_c/src/main.c
arrisde/dtasm
e8b4d114a5960c0a2bc31241c48af49dfc9dd498
[ "MIT" ]
3
2021-11-19T13:08:07.000Z
2022-02-04T09:46:17.000Z
runtime/examples/dtasmtime_c/src/main.c
arrisde/dtasm
e8b4d114a5960c0a2bc31241c48af49dfc9dd498
[ "MIT" ]
null
null
null
runtime/examples/dtasmtime_c/src/main.c
arrisde/dtasm
e8b4d114a5960c0a2bc31241c48af49dfc9dd498
[ "MIT" ]
2
2021-05-01T12:56:19.000Z
2021-10-04T14:09:53.000Z
// Copyright 2021 Siemens AG // SPDX-License-Identifier: MIT #include <stdio.h> #include <stdint.h> #include <inttypes.h> #include <math.h> // #include <sys/resource.h> #include <dtasmtime-c-api.h> int main(int argc, char *argv[]) { double tmin = 0.0; double tmax = 10.0; int n_steps = 1000; const char* dtasm_file; if (argc <= 1) { printf("Usage: dtasmtime-c dtasmModule.wasm [tmin=0.0] [tmax=10.0] [n_steps=1000] \n"); exit(0); } dtasm_file = argv[1]; if (argc > 2) { tmin = atof(argv[2]); } if (argc > 3) { tmax = atof(argv[3]); } if (argc > 4) { n_steps = atoi(argv[4]); } double dt = (tmax-tmin)/n_steps; printf("Creating engine... "); Engine *engine = dtasmtime_engine_new(); printf("Ok.\n"); printf("Creating Module... "); Module *module = dtasmtime_module_new(dtasm_file, engine); printf("Ok.\n"); printf("Instantiating Module... "); Instance *inst = dtasmtime_module_instantiate(module); printf("Ok.\n"); printf("Getting model description... \n"); DtasmModelDescription md = dtasmtime_modeldescription_get(inst); DtasmModelInfo mi = md.model; printf(" ID: %s,\n Name: %s,\n Description: %s,\n GenTool: %s \n", mi.id, mi.name, mi.description, mi.generation_tool); DtasmCapabilities cap = mi.capabilities; printf(" can_handle_variable_step_size: %d\n", cap.can_handle_variable_step_size); printf(" can_interpolate_inputs: %d\n", cap.can_interpolate_inputs); printf(" can_reset_step: %d\n", cap.can_interpolate_inputs); if (md.has_experiment) { DtasmExperimentInfo ei = md.experiment; printf(" Start time default: %f,\n End time default: %f,\n Timestep default: %f,\n Time unit: %s\n", ei.start_time_default, ei.end_time_default, ei.time_step_default, ei.time_unit); } printf("Variables: \n"); DtasmModelVariable *var = md.variables; int var_count = md.n_variables; int real_init_count = 0; int output_state_count = 0; for (int i=0; i<var_count; i++) { printf(" Name: %s\n", var[i].name); printf(" Desc: %s\n", var[i].description); printf(" Id: %d\n", var[i].id); if (var[i].has_default) { switch (var[i].value_type){ case DtasmReal: real_init_count++; printf(" Default value: %f\n", var[i].default_.real_val); break; } } if (var[i].causality == Output || var[i].causality == Local) output_state_count++; } DtasmVarValues initial_vals; initial_vals.n_reals = real_init_count; initial_vals.real_ids = malloc(real_init_count * sizeof(int)); initial_vals.real_values = malloc(real_init_count * sizeof(double)); //TODO: ints, bools and strings initial_vals.n_ints = 0; initial_vals.int_ids = NULL; initial_vals.int_values = NULL; initial_vals.n_bools = 0; initial_vals.bool_ids = NULL; initial_vals.bool_values = NULL; initial_vals.n_strings = 0; initial_vals.string_ids = NULL; initial_vals.string_values = NULL; int i_var = 0; for (int i=0; i<var_count; i++) { if (var[i].value_type == DtasmReal) { if (var[i].has_default) { initial_vals.real_ids[i_var] = var[i].id; initial_vals.real_values[i_var] = var[i].default_.real_val; i_var++; } } } printf("Calling initialize...\n"); DtasmStatus st = dtasmtime_initialize(inst, initial_vals, tmin, true, tmax, false, 0.0, DtasmLogWarn, false); printf("Returned %d\n", st); free(initial_vals.real_ids); free(initial_vals.real_values); int32_t * req_ids = malloc(output_state_count * sizeof(int)); int i_outvar = 0; for (int i=0; i<var_count; i++) { if (var[i].causality == Output || var[i].causality == Local) { req_ids[i_outvar] = var[i].id; i_outvar++; } } printf("Calling get values...\n"); DtasmGetValuesResponse get_vals_res = dtasmtime_getvalues(inst, req_ids, output_state_count); printf("Received status: %d\n", get_vals_res.status); printf("Current time: %f\n", get_vals_res.current_time); for (int i = 0; i < get_vals_res.values.n_reals; ++i) { printf("Value for var id %d: %f\n", get_vals_res.values.real_ids[i], get_vals_res.values.real_values[i]); } printf("Freeing getvalues res... "); dtasmtime_getvalues_free(get_vals_res); printf("Ok.\n"); double t = tmin; // struct rusage r_usage; // getrusage(RUSAGE_SELF,&r_usage); // printf("Memory usage: %ld kilobytes\n", r_usage.ru_maxrss); for (int i=0; i<n_steps; ++i) { printf("Calling do_step...\n"); DtasmDoStepResponse dostep_res = dtasmtime_dostep(inst, t, dt); printf("Returned %d, updated time %f\n", dostep_res.status, dostep_res.updated_time); get_vals_res = dtasmtime_getvalues(inst, req_ids, output_state_count); for (int i = 0; i < get_vals_res.values.n_reals; ++i) { printf("Value for var id %d: %f\n", get_vals_res.values.real_ids[i], get_vals_res.values.real_values[i]); } dtasmtime_getvalues_free(get_vals_res); // getrusage(RUSAGE_SELF,&r_usage); // printf("Memory usage: %ld kilobytes\n", r_usage.ru_maxrss); t = dostep_res.updated_time; } printf("Freeing model description... "); dtasmtime_modeldescription_free(md); printf("Ok.\n"); printf("Freeing Instance... "); dtasmtime_instance_free(inst); printf("Ok.\n"); printf("Freeing Module... "); dtasmtime_module_free(module); printf("Ok.\n"); printf("Freeing Engine... "); dtasmtime_engine_free(engine); printf("Ok.\n"); }
28.908213
123
0.603443
9c3cbae2d4bdf44509ad4c924dd3000e7a7b3a8f
4,555
h
C
drivers/platform/surface/aggregator/ssh_request_layer.h
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
44
2022-03-16T08:32:31.000Z
2022-03-31T16:02:35.000Z
drivers/platform/surface/aggregator/ssh_request_layer.h
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
1
2021-01-27T01:29:47.000Z
2021-01-27T01:29:47.000Z
drivers/platform/surface/aggregator/ssh_request_layer.h
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
18
2022-03-19T04:41:04.000Z
2022-03-31T03:32:12.000Z
/* SPDX-License-Identifier: GPL-2.0+ */ /* * SSH request transport layer. * * Copyright (C) 2019-2021 Maximilian Luz <luzmaximilian@gmail.com> */ #ifndef _SURFACE_AGGREGATOR_SSH_REQUEST_LAYER_H #define _SURFACE_AGGREGATOR_SSH_REQUEST_LAYER_H #include <linux/atomic.h> #include <linux/ktime.h> #include <linux/list.h> #include <linux/spinlock.h> #include <linux/workqueue.h> #include <linux/surface_aggregator/serial_hub.h> #include <linux/surface_aggregator/controller.h> #include "ssh_packet_layer.h" /** * enum ssh_rtl_state_flags - State-flags for &struct ssh_rtl. * * @SSH_RTL_SF_SHUTDOWN_BIT: * Indicates that the request transport layer has been shut down or is * being shut down and should not accept any new requests. */ enum ssh_rtl_state_flags { SSH_RTL_SF_SHUTDOWN_BIT, }; /** * struct ssh_rtl_ops - Callback operations for request transport layer. * @handle_event: Function called when a SSH event has been received. The * specified function takes the request layer, received command * struct, and corresponding payload as arguments. If the event * has no payload, the payload span is empty (not %NULL). */ struct ssh_rtl_ops { void (*handle_event)(struct ssh_rtl *rtl, const struct ssh_command *cmd, const struct ssam_span *data); }; /** * struct ssh_rtl - SSH request transport layer. * @ptl: Underlying packet transport layer. * @state: State(-flags) of the transport layer. * @queue: Request submission queue. * @queue.lock: Lock for modifying the request submission queue. * @queue.head: List-head of the request submission queue. * @pending: Set/list of pending requests. * @pending.lock: Lock for modifying the request set. * @pending.head: List-head of the pending set/list. * @pending.count: Number of currently pending requests. * @tx: Transmitter subsystem. * @tx.work: Transmitter work item. * @rtx_timeout: Retransmission timeout subsystem. * @rtx_timeout.lock: Lock for modifying the retransmission timeout reaper. * @rtx_timeout.timeout: Timeout interval for retransmission. * @rtx_timeout.expires: Time specifying when the reaper work is next scheduled. * @rtx_timeout.reaper: Work performing timeout checks and subsequent actions. * @ops: Request layer operations. */ struct ssh_rtl { struct ssh_ptl ptl; unsigned long state; struct { spinlock_t lock; struct list_head head; } queue; struct { spinlock_t lock; struct list_head head; atomic_t count; } pending; struct { struct work_struct work; } tx; struct { spinlock_t lock; ktime_t timeout; ktime_t expires; struct delayed_work reaper; } rtx_timeout; struct ssh_rtl_ops ops; }; #define rtl_dbg(r, fmt, ...) ptl_dbg(&(r)->ptl, fmt, ##__VA_ARGS__) #define rtl_info(p, fmt, ...) ptl_info(&(p)->ptl, fmt, ##__VA_ARGS__) #define rtl_warn(r, fmt, ...) ptl_warn(&(r)->ptl, fmt, ##__VA_ARGS__) #define rtl_err(r, fmt, ...) ptl_err(&(r)->ptl, fmt, ##__VA_ARGS__) #define rtl_dbg_cond(r, fmt, ...) __ssam_prcond(rtl_dbg, r, fmt, ##__VA_ARGS__) #define to_ssh_rtl(ptr, member) \ container_of(ptr, struct ssh_rtl, member) /** * ssh_rtl_get_device() - Get device associated with request transport layer. * @rtl: The request transport layer. * * Return: Returns the device on which the given request transport layer * builds upon. */ static inline struct device *ssh_rtl_get_device(struct ssh_rtl *rtl) { return ssh_ptl_get_device(&rtl->ptl); } /** * ssh_request_rtl() - Get request transport layer associated with request. * @rqst: The request to get the request transport layer reference for. * * Return: Returns the &struct ssh_rtl associated with the given SSH request. */ static inline struct ssh_rtl *ssh_request_rtl(struct ssh_request *rqst) { struct ssh_ptl *ptl; ptl = READ_ONCE(rqst->packet.ptl); return likely(ptl) ? to_ssh_rtl(ptl, ptl) : NULL; } int ssh_rtl_submit(struct ssh_rtl *rtl, struct ssh_request *rqst); bool ssh_rtl_cancel(struct ssh_request *rqst, bool pending); int ssh_rtl_init(struct ssh_rtl *rtl, struct serdev_device *serdev, const struct ssh_rtl_ops *ops); int ssh_rtl_start(struct ssh_rtl *rtl); int ssh_rtl_flush(struct ssh_rtl *rtl, unsigned long timeout); void ssh_rtl_shutdown(struct ssh_rtl *rtl); void ssh_rtl_destroy(struct ssh_rtl *rtl); int ssh_request_init(struct ssh_request *rqst, enum ssam_request_flags flags, const struct ssh_request_ops *ops); #endif /* _SURFACE_AGGREGATOR_SSH_REQUEST_LAYER_H */
31.631944
80
0.725796
80d3ce73eb2f5f918dde6c9d038cc1f9a5e368fd
537
h
C
TestStaticLibrary/TestStaticLibrary.h
CoderZHL/TestStaticLibrary
cb2c25b9e3a202780c9304355ca0cd504087b9f5
[ "MIT" ]
null
null
null
TestStaticLibrary/TestStaticLibrary.h
CoderZHL/TestStaticLibrary
cb2c25b9e3a202780c9304355ca0cd504087b9f5
[ "MIT" ]
null
null
null
TestStaticLibrary/TestStaticLibrary.h
CoderZHL/TestStaticLibrary
cb2c25b9e3a202780c9304355ca0cd504087b9f5
[ "MIT" ]
null
null
null
// // TestStaticLibrary.h // TestStaticLibrary // // Created by 钟浩良 on 2018/2/5. // Copyright © 2018年 钟浩良. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for TestStaticLibrary. FOUNDATION_EXPORT double TestStaticLibraryVersionNumber; //! Project version string for TestStaticLibrary. FOUNDATION_EXPORT const unsigned char TestStaticLibraryVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <TestStaticLibrary/PublicHeader.h>
26.85
142
0.780261
3b82afd1d00c91c6dea39dff380a7984314a3a3e
147
h
C
Photino.Native/Photino.Mac.AppDelegate.h
MiniguyBrendan/photino.Native
fa6f56c82976c6a45260afb47316cebe2cd145dc
[ "Apache-2.0" ]
null
null
null
Photino.Native/Photino.Mac.AppDelegate.h
MiniguyBrendan/photino.Native
fa6f56c82976c6a45260afb47316cebe2cd145dc
[ "Apache-2.0" ]
null
null
null
Photino.Native/Photino.Mac.AppDelegate.h
MiniguyBrendan/photino.Native
fa6f56c82976c6a45260afb47316cebe2cd145dc
[ "Apache-2.0" ]
null
null
null
#pragma once #include <Cocoa/Cocoa.h> @interface AppDelegate : NSObject <NSApplicationDelegate, NSWindowDelegate> { NSWindow * window; } @end
18.375
77
0.748299
3bfc9844c5252cff06203b12ba6206b72ab10a39
598
c
C
sw/lib/mpi/mpi_init.c
domso/rcmc
e442772bfcc9607fadfbfc5a4f02af2d330dd8d4
[ "ISC" ]
4
2018-04-17T21:47:00.000Z
2019-06-02T19:49:23.000Z
sw/lib/mpi/mpi_init.c
domso/rcmc
e442772bfcc9607fadfbfc5a4f02af2d330dd8d4
[ "ISC" ]
1
2019-03-17T17:28:57.000Z
2019-03-17T17:28:57.000Z
sw/lib/mpi/mpi_init.c
domso/rcmc
e442772bfcc9607fadfbfc5a4f02af2d330dd8d4
[ "ISC" ]
2
2018-01-04T03:05:29.000Z
2019-02-28T15:01:43.000Z
#include "mpi_internal.h" #ifdef NEW_PIMP // for fgmp.h // need not be initialised, because it is cleared by the CRT anyway flit_t fgmp_first_flit[FGMP_MAX_CID]; char fgmp_flit_buffered[FGMP_MAX_CID]; #endif mpi_request_t request_slot[MAX_REQUESTS]; mpi_communicator_t mpi_comm_world; int MPI_Init(int *argc, char ***argv) { // for nonblocking receive int i; for (i=0; i<MAX_REQUESTS; i++) request_slot[i].used = 0; mpi_comm_world.rank = fgmp_get_cid(); mpi_comm_world.group.size = fgmp_get_max_cid(); mpi_comm_world.group.cids[0] = 0; return MPI_SUCCESS; }
23.92
67
0.72408
026e73d276c2ea8d0d5e6d9242ae1f36605bf3ab
1,384
h
C
tools/runner/ipcclient.h
sparkleholic/qml-webos-framework
dbf1f8608ae88b189dedd358acc97d9504425996
[ "Apache-2.0" ]
12
2018-03-17T12:35:32.000Z
2021-10-15T09:04:56.000Z
tools/runner/ipcclient.h
sparkleholic/qml-webos-framework
dbf1f8608ae88b189dedd358acc97d9504425996
[ "Apache-2.0" ]
2
2020-05-28T14:58:01.000Z
2022-02-04T04:03:07.000Z
tools/runner/ipcclient.h
sparkleholic/qml-webos-framework
dbf1f8608ae88b189dedd358acc97d9504425996
[ "Apache-2.0" ]
5
2018-03-22T18:54:18.000Z
2020-03-04T19:20:01.000Z
// Copyright (c) 2014-2018 LG Electronics, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 #ifndef IPCCLIENT_H #define IPCCLIENT_H #include <QtCore/QObject> #include <QtCore/QPointer> #include <QtNetwork/QLocalSocket> #include "../common/ipccommon.h" class QLocalSocket; class QJsonDocument; class IpcClient : public QObject { Q_OBJECT public: IpcClient(QObject * parent = 0); virtual ~IpcClient(); void send(const QJsonDocument &json); signals: void launchRequest(const QString &, const QString &, const QJsonDocument &); void relaunchRequest(const QJsonDocument &); public slots: bool connectToServer(); private slots: void onSocketReadyRead(); void onSocketError(QLocalSocket::LocalSocketError socketError); private: QPointer <QLocalSocket> m_socket; }; #endif // IPCCLIENT_H
25.163636
80
0.739162
7e46cc01505ef21c275f8e3f8984b6176e51c8ac
420
h
C
src/include/lem/solarix/CoordEnumerator.h
name212/GrammarEngine
1912809d6a19977c9d2fff88279b76a6152b659d
[ "MIT" ]
55
2015-04-11T17:39:27.000Z
2022-01-07T17:52:22.000Z
src/include/lem/solarix/CoordEnumerator.h
name212/GrammarEngine
1912809d6a19977c9d2fff88279b76a6152b659d
[ "MIT" ]
17
2017-11-22T13:31:11.000Z
2021-06-06T08:30:43.000Z
src/include/lem/solarix/CoordEnumerator.h
qwazer/GrammarEngine
08e1eb7bdfd77f29a51a7063848d74b9171291c4
[ "MIT" ]
28
2015-05-21T08:27:31.000Z
2022-02-24T21:42:36.000Z
#if !defined CoordEnumerator__H #define CoordEnumerator__H #include <lem/noncopyable.h> namespace Solarix { class GramCoord; class CoordEnumerator : lem::NonCopyable { protected: CoordEnumerator(void) {} public: virtual ~CoordEnumerator(void) {} virtual bool Fetch(void)=0; virtual int GetId(void)=0; virtual const GramCoord& GetItem(void)=0; }; } #endif
18.26087
46
0.657143
f1578cb1acc3cb0b5ad86c67212d4caf4e5419de
604
h
C
components/external_video_surface/component_jni_registrar.h
Wzzzx/chromium-crosswalk
768dde8efa71169f1c1113ca6ef322f1e8c9e7de
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2019-01-28T08:09:58.000Z
2021-11-15T15:32:10.000Z
components/external_video_surface/component_jni_registrar.h
maidiHaitai/haitaibrowser
a232a56bcfb177913a14210e7733e0ea83a6b18d
[ "BSD-3-Clause" ]
null
null
null
components/external_video_surface/component_jni_registrar.h
maidiHaitai/haitaibrowser
a232a56bcfb177913a14210e7733e0ea83a6b18d
[ "BSD-3-Clause" ]
6
2020-09-23T08:56:12.000Z
2021-11-18T03:40:49.000Z
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_EXTERNAL_VIDEO_SURFACE_COMPONENT_JNI_REGISTRAR_H_ #define COMPONENTS_EXTERNAL_VIDEO_SURFACE_COMPONENT_JNI_REGISTRAR_H_ #include <jni.h> namespace external_video_surface { // Register all JNI bindings necessary for the external_video_surface component. bool RegisterExternalVideoSurfaceJni(JNIEnv* env); } // namespace external_video_surface #endif // COMPONENTS_EXTERNAL_VIDEO_SURFACE_COMPONENT_JNI_REGISTRAR_H_
33.555556
80
0.839404
019db1a5449f2ac7937b6efcd1c4b21160f5d1b8
2,211
h
C
ios/chrome/browser/ui/settings/cells/table_view_clear_browsing_data_item.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
ios/chrome/browser/ui/settings/cells/table_view_clear_browsing_data_item.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
113
2015-05-04T09:58:14.000Z
2022-01-31T19:35:03.000Z
ios/chrome/browser/ui/settings/cells/table_view_clear_browsing_data_item.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_TABLE_VIEW_CLEAR_BROWSING_DATA_ITEM_H_ #define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_TABLE_VIEW_CLEAR_BROWSING_DATA_ITEM_H_ #import "ios/chrome/browser/ui/table_view/cells/table_view_item.h" enum class BrowsingDataRemoveMask; // TableViewClearBrowsingDataItem contains the model data for a // TableViewTextCell in addition a BrowsingDataRemoveMask property. @interface TableViewClearBrowsingDataItem : TableViewItem @property(nonatomic, copy) NSString* imageName; @property(nonatomic, copy) NSString* text; @property(nonatomic, copy) NSString* detailText; @property(nonatomic, copy) NSString* optionalText; // Whether or not this item is checked. @property(nonatomic, assign) BOOL checked; // Background color for the cell's backgroundView when self.checked == YES // Is copied to the cell's highlightedBackgroundColor @property(nonatomic, strong) UIColor* checkedBackgroundColor; // Mask of the data to be cleared. @property(nonatomic, assign) BrowsingDataRemoveMask dataTypeMask; // Pref name associated with the item. @property(nonatomic, assign) const char* prefName; @end // TableViewClearBrowsingDataCell implements an TableViewCell subclass // containing a leading image icon and three text labels: a "title" label, a // "detail" label, and an optional third label in case we need more description // for the item. All three labels are laid out one after the other vertically // and fill the full width of the cell. @interface TableViewClearBrowsingDataCell : TableViewCell @property(nonatomic, strong) UILabel* textLabel; @property(nonatomic, strong) UILabel* detailTextLabel; @property(nonatomic, strong) UILabel* optionalTextLabel; // Whether or not this cell is checked. @property(nonatomic, assign) BOOL checked; // Background color for this cell's backgroundView when highlighted @property(nonatomic, strong) UIColor* highlightedBackgroundColor; - (void)setImage:(UIImage*)image; @end #endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_TABLE_VIEW_CLEAR_BROWSING_DATA_ITEM_H_
38.12069
86
0.810493
d7d9da44f032ba363bdb4318931921190a276970
6,031
h
C
mam/v2/defs.h
semenov-vladyslav/entangled
a3be602d6e2a42472b4c655d048620daa16628ce
[ "Apache-2.0" ]
null
null
null
mam/v2/defs.h
semenov-vladyslav/entangled
a3be602d6e2a42472b4c655d048620daa16628ce
[ "Apache-2.0" ]
null
null
null
mam/v2/defs.h
semenov-vladyslav/entangled
a3be602d6e2a42472b4c655d048620daa16628ce
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2018 IOTA Stiftung * https://github.com/iotaledger/entangled * * MAM is based on an original implementation & specification by apmi.bsu.by [ITSec Lab] * * * Refer to the LICENSE file for licensing information */ /*! \file defs.h \brief MAM2 common definitions. */ #ifndef __MAM_V2_DEFS_H__ #define __MAM_V2_DEFS_H__ /*! \brief Enable debug output macros. */ //#define MAM2_DEBUG #include <stddef.h> #include <stdint.h> #if defined(NDEBUG) //&& defined(MAM2_DEBUG) // enable `assert` in RELEASE #undef NDEBUG #include <assert.h> #define NDEBUG #endif #include <assert.h> #ifdef MAM2_DEBUG #include <stdio.h> #define dbg_printf(...) printf(__VA_ARGS__) #else #define dbg_printf(...) #endif /*! \brief word_t should be thought of as ternary processor register. Although it can consist of several trytes here it is considered as an atomic vector of trits. In binary computer and in C language this type is tunable and can be represented with uintX_t types of using binary-coded representation. Client code should make no assumptions regarding it's representation and should operate upon using macros presented in this module. In order to optimize sequential processing at Sponge layer a blocks of 486 trits should consist of whole number of words, meaning 486 should be a multiple of TRITS_PER_WORD: 1,2,3,6,9,18,27,54,81. Otherwise it would require inefficient shifts or unpacking. */ #if !defined(MAM2_TRITS_PER_WORD) || !(MAM2_TRITS_PER_WORD > 0) #error MAM2_TRITS_PER_WORD is not defined or is not positive. #endif #if defined(MAM2_TRINARY_WORD_REP_INT) /*! \brief Single-trit word representation `word_t` consists of one trit. #define MAM2_TRINARY_WORD_REP_INT_T int8_t #define MAM2_TRITS_PER_WORD 1 or #define MAM2_TRITS_PER_WORD 5 */ #ifndef MAM2_TRINARY_WORD_REP_INT_T #if (MAM2_TRITS_PER_WORD <= 5) #define MAM2_TRINARY_WORD_REP_INT_T int8_t #elif (MAM2_TRITS_PER_WORD <= 10) #define MAM2_TRINARY_WORD_REP_INT_T int16_t #elif (MAM2_TRITS_PER_WORD <= 20) #define MAM2_TRINARY_WORD_REP_INT_T int32_t #elif (MAM2_TRITS_PER_WORD <= 40) #define MAM2_TRINARY_WORD_REP_INT_T int64_t #else #error "Can't represent word_t for specified MAM2_TRITS_PER_WORD." #endif #endif typedef MAM2_TRINARY_WORD_REP_INT_T rep_t; typedef rep_t word_t; #elif defined(MAM2_TRINARY_WORD_REP_INTERLEAVED) /*! \brief Interleaved word representation `word_t` is represented using two bit arrays (unsigned ints). (lo,hi): (0,0)=(1,1)=0 (0,1)=1 (1,0)=-1 #define MAM2_TRINARY_WORD_REP_INTERLEAVED_T uint8_t #define MAM2_TRITS_PER_WORD 8 or #define MAM2_TRINARY_WORD_REP_INTERLEAVED_T uint32_t #define MAM2_TRITS_PER_WORD 27 */ #ifndef MAM2_TRINARY_WORD_REP_INTERLEAVED_T #if (MAM2_TRITS_PER_WORD <= 8) #define MAM2_TRINARY_WORD_REP_INTERLEAVED_T int8_t #elif (MAM2_TRITS_PER_WORD <= 16) #define MAM2_TRINARY_WORD_REP_INTERLEAVED_T int16_t #elif (MAM2_TRITS_PER_WORD <= 32) #define MAM2_TRINARY_WORD_REP_INTERLEAVED_T int32_t #elif (MAM2_TRITS_PER_WORD <= 64) #define MAM2_TRINARY_WORD_REP_INTERLEAVED_T int64_t #else #error "Can't represent word_t for specified MAM2_TRITS_PER_WORD." #endif #endif typedef MAM2_TRINARY_WORD_REP_INTERLEAVED_T rep_t; typedef struct { rep_t lo, hi; } word_t; #define MAM2_WORD_TRIT_IS_ZERO(w, t) \ ((((w).lo ^ (w).hi) & ((word_t)1) << (t)) == 0) #elif defined(MAM2_TRINARY_WORD_REP_PACKED) //#define MAM2_TRINARY_WORD_REP_PACKED_T uint8_t //#define MAM2_TRITS_PER_WORD 3 #ifndef MAM2_TRINARY_WORD_REP_PACKED_T #if (MAM2_TRITS_PER_WORD <= 4) #define MAM2_TRINARY_WORD_REP_PACKED_T int8_t #elif (MAM2_TRITS_PER_WORD <= 8) #define MAM2_TRINARY_WORD_REP_PACKED_T int16_t #elif (MAM2_TRITS_PER_WORD <= 16) #define MAM2_TRINARY_WORD_REP_PACKED_T int32_t #elif (MAM2_TRITS_PER_WORD <= 32) #define MAM2_TRINARY_WORD_REP_PACKED_T int64_t #else #error "Can't represent word_t for specified MAM2_TRITS_PER_WORD." #endif #endif typedef MAM2_TRINARY_WORD_REP_PACKED_T rep_t; typedef rep_t word_t; #else #error MAM2_TRINARY_WORD representation is not selected. \ Please, define one of MAM2_TRINARY_WORD_REP_INT, \ MAM2_TRINARY_WORD_REP_INTERLEAVED, \ or MAM2_TRINARY_WORD_REP_PACKED. #endif /*! \brief Minimum number of words needed to represent `t` trits */ #define MAM2_WORDS(t) (((t) + MAM2_TRITS_PER_WORD - 1) / MAM2_TRITS_PER_WORD) /*! `M = 3^n`, `m = 3^k`, `n>k`. t \in [-(M-1)/2 .. (M-1)/2]. */ #define MAM2_MODS(t, M, m) ((((t) + ((M - 1) / 2)) % (m)) - ((m - 1) / 2)) #define MAM2_DIVS(t, M, m) ((((t) + ((M - 1) / 2)) / (m)) - ((M / m - 1) / 2)) /*! \brief Signed integer type capable of storing single trit with values in range [-1,0,1]. */ typedef int8_t trint1_t; typedef trint1_t trit_t; #define MAM2_ASSERT_TRINT1(t1) \ MAM2_ASSERT(((t1) == (trint1_t)-1) || ((t1) == (trint1_t)0) || \ ((t1) == (trint1_t)1)) /*! \brief Boolean type with zero as `false`(`no`) and non-zero as * `true`(`yes`). */ typedef trint1_t bool_t; /*! \brief Signed integer type capable of storing 3 trits with values in range [-13,..,-1,0,1,..,13]. */ typedef int8_t trint3_t; typedef trint3_t tryte_t; static char tryte_to_char(tryte_t t); static bool_t tryte_from_char(tryte_t *t, char c); /*! \brief Signed integer type capable of storing 6 trits with values in range [-(3^6-1)/2=-364,..,-1,0,1,..,364=(3^6-1)/2]. */ typedef int16_t trint6_t; /*! \brief Signed integer type capable of storing 9 trits with values in range [-(3^9-1)/2=-9841,..,-1,0,1,..,9841=(3^9-1)/2]. */ typedef int16_t trint9_t; /*! \brief Signed integer type capable of storing 18 trits with values in range [-(3^18-1)/2,..,-1,0,1,..,(3^18-1)/2]. */ typedef int32_t trint18_t; /*! \note `trintX_t` types represent integer values whereas `word_t` type represents fixed-size set of trits. */ /*! Unsigned 8-bit type. */ typedef uint8_t byte; /*! \brief Assert expression. */ #define MAM2_ASSERT(expr) assert(expr) // TODO - Figure out what to do with those (@tsvisabo) #define MAM2_API #define MAM2_SAPI #define MAM2_INLINE #endif // __MAM_V2_DEFS_H__
29.135266
79
0.743492
0bbaf23f928645614448fc6d59d6b756541c924f
798
h
C
src/main/include/OI.h
TonyTheFlower/tsa-robotics-robot
a559fd0659e96bc9d286c637f1294d3903898ea8
[ "BSD-3-Clause" ]
1
2021-12-01T01:26:07.000Z
2021-12-01T01:26:07.000Z
src/main/include/OI.h
TonyTheFlower/tsa-robotics-robot
a559fd0659e96bc9d286c637f1294d3903898ea8
[ "BSD-3-Clause" ]
null
null
null
src/main/include/OI.h
TonyTheFlower/tsa-robotics-robot
a559fd0659e96bc9d286c637f1294d3903898ea8
[ "BSD-3-Clause" ]
null
null
null
//! Operator Interface allows various commands to access the xbox controllers through the DriverStation #ifndef _OI_HG_ #define _OI_HG_ #include <frc/WPILib.h> #include <frc/XboxController.h> class OI { public: OI(); //!< Class constructor /** * Function for getting the Driver's joystick data * * @return Pointer to the driver's joystick */ frc::XboxController* GetJoystickDrive(void); /** * Function for getting the Operator's joystick data * * @return Pointer to the operator's joystick */ frc::XboxController* GetJoystickOperator(void); private: frc::XboxController* pJoystickDrive; //!< Pointer for Driver's joystick frc::XboxController* pJoystickOperator; //!< Pointer for Operator's joystick }; #endif // _OI_HG_
25.741935
104
0.68797
cc848e48d027bb52caf63a91884e81c9711ca325
1,330
c
C
distributed_endurer/c_models_test/c_lstm2/activation_mask_NR_TENYEAR.c
robust-systems-group/illusion_system
f142cc1dacb02312ad78b0ec613061fe84e6648c
[ "BSD-3-Clause" ]
4
2021-01-22T14:28:02.000Z
2021-12-21T10:12:35.000Z
distributed_endurer/c_models_test/c_lstm2/activation_mask_NR_TENYEAR.c
robust-systems-group/illusion_system
f142cc1dacb02312ad78b0ec613061fe84e6648c
[ "BSD-3-Clause" ]
null
null
null
distributed_endurer/c_models_test/c_lstm2/activation_mask_NR_TENYEAR.c
robust-systems-group/illusion_system
f142cc1dacb02312ad78b0ec613061fe84e6648c
[ "BSD-3-Clause" ]
null
null
null
int16_t chip0_forced_zeros[10] = { 0,1346, 32,2112, 64, 34, 256, 72, 256, 48}; int16_t chip0_forced_ones[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int16_t chip1_forced_zeros[10] = { 8208, 4612, 1024,-32576, 272, 32, 16,-32767, 128, 320}; int16_t chip1_forced_ones[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int16_t chip2_forced_zeros[10] = { 0, 112, 2056, 2128, 8192, 0, 4232, 4624,-32672, 256}; int16_t chip2_forced_ones[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int16_t chip3_forced_zeros[10] = { 0, 528, 8448, 16, 4100,-30720, 512, 1536,-32768, 672}; int16_t chip3_forced_ones[10] = { -1, -1, -1, -1,-17, -1, -1, -1, -1, -1}; int16_t chip4_forced_zeros[10] = { 0, 8468, 1024, 2560, 768, 25088, 16,-24576, 0, 130}; int16_t chip4_forced_ones[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int16_t chip5_forced_zeros[10] = {0,0,0,0,0,0,0,0,0,0}; int16_t chip5_forced_ones[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int16_t chip6_forced_zeros[10] = { 273, 256, 2048,-32248, 1552, 256, 1152, 20480, 8256, 136}; int16_t chip6_forced_ones[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int16_t chip7_forced_zeros[10] = { 128, 128, 16, 5772, 512, 640, 40, 2048,28770, 2568}; int16_t chip7_forced_ones[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
40.30303
72
0.56015
9e354f0ddef2b12ce334f6fb8c53e7e03310f66c
3,480
h
C
meeting-qt/meeting-ipc/third_party/openssl/include/windows/openssl/seed.h
GrowthEase/-
5cc7cab95fc309049de8023ff618219dff22d773
[ "MIT" ]
48
2022-03-02T07:15:08.000Z
2022-03-31T08:37:33.000Z
meeting-qt/meeting-ipc/third_party/openssl/include/windows/openssl/seed.h
chandarlee/Meeting
9350fdea97eb2cdda28b8bffd9c4199de15460d9
[ "MIT" ]
1
2022-01-01T03:39:46.000Z
2022-01-01T03:39:46.000Z
meeting-qt/meeting-ipc/third_party/openssl/include/windows/openssl/seed.h
chandarlee/Meeting
9350fdea97eb2cdda28b8bffd9c4199de15460d9
[ "MIT" ]
9
2022-03-01T13:41:37.000Z
2022-03-10T06:05:23.000Z
/* * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ /* * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Neither the name of author nor the names of its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef HEADER_SEED_H # define HEADER_SEED_H # include <openssl/opensslconf.h> # ifndef OPENSSL_NO_SEED # include <openssl/e_os2.h> # include <openssl/crypto.h> #ifdef __cplusplus extern "C" { #endif /* look whether we need 'long' to get 32 bits */ # ifdef AES_LONG # ifndef SEED_LONG # define SEED_LONG 1 # endif # endif # include <sys/types.h> # define SEED_BLOCK_SIZE 16 # define SEED_KEY_LENGTH 16 typedef struct seed_key_st { # ifdef SEED_LONG unsigned long data[32]; # else unsigned int data[32]; # endif } SEED_KEY_SCHEDULE; void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], SEED_KEY_SCHEDULE *ks); void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], unsigned char d[SEED_BLOCK_SIZE], const SEED_KEY_SCHEDULE *ks); void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], unsigned char d[SEED_BLOCK_SIZE], const SEED_KEY_SCHEDULE *ks); void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, const SEED_KEY_SCHEDULE *ks, int enc); void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int enc); void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int *num, int enc); void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int *num); # ifdef __cplusplus } # endif # endif #endif
35.876289
83
0.702586
d273981eadd10b301e920390ca8287c90d8151a8
1,127
h
C
src/mdp/learning/reinforcementLearning/actionValuesFunction/polynomialNetwork.h
Jacques-Florence/SchedSim
cd5f356ec1d177963d401b69996a19a68646d7af
[ "BSD-3-Clause" ]
1
2019-12-24T19:07:19.000Z
2019-12-24T19:07:19.000Z
src/mdp/learning/reinforcementLearning/actionValuesFunction/polynomialNetwork.h
Jacques-Florence/SchedSim
cd5f356ec1d177963d401b69996a19a68646d7af
[ "BSD-3-Clause" ]
null
null
null
src/mdp/learning/reinforcementLearning/actionValuesFunction/polynomialNetwork.h
Jacques-Florence/SchedSim
cd5f356ec1d177963d401b69996a19a68646d7af
[ "BSD-3-Clause" ]
null
null
null
/** * Copyright 2017 Jacques Florence * All rights reserved. * See License.txt file * */ #ifndef POLYNOMIAL_NETWORK_H #define POLYNOMIAL_NETWORK_H #include "approximatedFunction.h" namespace Mdp { struct context; class PolynomialNetwork : public ApproximatedFunction { public: PolynomialNetwork(std::shared_ptr<Context> context, size_t inputSize, size_t outputSize, size_t nbOfHiddenLayers); std::vector<double> getParamVector() override; std::vector<double> getOutput(std::vector<double> input) override; void learnExample(std::vector<double> input, std::vector<double> output) override; void initializeWeights(std::vector<std::vector<double>> inputWeights, std::vector<std::vector<double>> outputWeights); double getValue(state_t s, action_t a); std::vector<double> getValues(state_t s); void updateParameters(double coeff); void setAlpha(double alpha); protected: void init(std::shared_ptr<Context> context); size_t hiddenSize{0}; std::vector<double> hiddenLayer; std::vector<std::vector<double>> inputWeights; std::vector<std::vector<double>> outputWeights; }; } #endif
25.613636
115
0.75244
2caf0f961d49981ca4466ea021df08495c256086
565
h
C
components/gameboy/defs.h
hi631/esp32-gbemu
46562de87c5eea2cdde6907b4e866e0e9122ddbf
[ "Apache-2.0" ]
5
2018-01-15T10:57:07.000Z
2019-12-04T08:48:09.000Z
components/gameboy/defs.h
hi631/esp32-gbemu
46562de87c5eea2cdde6907b4e866e0e9122ddbf
[ "Apache-2.0" ]
1
2018-08-24T11:37:55.000Z
2018-12-27T04:51:44.000Z
components/gameboy/defs.h
hi631/esp32-gbemu
46562de87c5eea2cdde6907b4e866e0e9122ddbf
[ "Apache-2.0" ]
4
2018-04-15T13:50:35.000Z
2019-12-04T08:48:17.000Z
#ifndef __DEFS_H__ #define __DEFS_H__ #define IS_LITTLE_ENDIAN //#include <stdio.h> //#include <math.h> //#include <stdlib.h> //#define INLINE static __inline #undef byte #undef word #ifdef IS_LITTLE_ENDIAN #define LO 0 #define HI 1 #else #define LO 1 #define HI 0 #endif //ifndef GP32 typedef unsigned char byte; //endif typedef unsigned char un8; typedef unsigned short un16; typedef unsigned int un32; typedef signed char n8; typedef signed short n16; typedef signed int n32; //ifndef GP32 typedef un16 word; //endif typedef word addr; #endif
11.3
32
0.739823
d216ba5b86c8bf36cede757cf5f2fa88cdca6c88
8,154
c
C
src/pipewire/impl-factory.c
cropinghigh/pipewire
2e199eba4374acc6e96e002d4d0166a1a665639d
[ "MIT" ]
null
null
null
src/pipewire/impl-factory.c
cropinghigh/pipewire
2e199eba4374acc6e96e002d4d0166a1a665639d
[ "MIT" ]
null
null
null
src/pipewire/impl-factory.c
cropinghigh/pipewire
2e199eba4374acc6e96e002d4d0166a1a665639d
[ "MIT" ]
null
null
null
/* PipeWire * * Copyright © 2018 Wim Taymans * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include <errno.h> #include <spa/debug/types.h> #include <spa/utils/string.h> #include "pipewire/impl.h" #include "pipewire/private.h" PW_LOG_TOPIC_EXTERN(log_factory); #define PW_LOG_TOPIC_DEFAULT log_factory #define pw_factory_resource_info(r,...) pw_resource_call(r,struct pw_factory_events,info,0,__VA_ARGS__) SPA_EXPORT struct pw_impl_factory *pw_context_create_factory(struct pw_context *context, const char *name, const char *type, uint32_t version, struct pw_properties *properties, size_t user_data_size) { struct pw_impl_factory *this; int res; if (properties == NULL) properties = pw_properties_new(NULL, NULL); if (properties == NULL) return NULL; this = calloc(1, sizeof(*this) + user_data_size); if (this == NULL) { res = -errno; goto error_exit; }; this->context = context; this->properties = properties; this->info.name = strdup(name); this->info.type = type; this->info.version = version; this->info.props = &properties->dict; spa_hook_list_init(&this->listener_list); if (user_data_size > 0) this->user_data = SPA_PTROFF(this, sizeof(*this), void); pw_log_debug("%p: new %s", this, name); return this; error_exit: pw_properties_free(properties); errno = -res; return NULL; } SPA_EXPORT void pw_impl_factory_destroy(struct pw_impl_factory *factory) { pw_log_debug("%p: destroy", factory); pw_impl_factory_emit_destroy(factory); if (factory->registered) spa_list_remove(&factory->link); if (factory->global) { spa_hook_remove(&factory->global_listener); pw_global_destroy(factory->global); } pw_impl_factory_emit_free(factory); pw_log_debug("%p: free", factory); spa_hook_list_clean(&factory->listener_list); free((char *)factory->info.name); pw_properties_free(factory->properties); free(factory); } static int global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions, uint32_t version, uint32_t id) { struct pw_impl_factory *this = _data; struct pw_global *global = this->global; struct pw_resource *resource; resource = pw_resource_new(client, id, permissions, global->type, version, 0); if (resource == NULL) goto error_resource; pw_log_debug("%p: bound to %d", this, resource->id); pw_global_add_resource(global, resource); this->info.change_mask = PW_FACTORY_CHANGE_MASK_ALL; pw_factory_resource_info(resource, &this->info); this->info.change_mask = 0; return 0; error_resource: pw_log_error("%p: can't create factory resource: %m", this); return -errno; } static void global_destroy(void *object) { struct pw_impl_factory *factory = object; spa_hook_remove(&factory->global_listener); factory->global = NULL; pw_impl_factory_destroy(factory); } static const struct pw_global_events global_events = { PW_VERSION_GLOBAL_EVENTS, .destroy = global_destroy, }; SPA_EXPORT const struct pw_properties *pw_impl_factory_get_properties(struct pw_impl_factory *factory) { return factory->properties; } SPA_EXPORT int pw_impl_factory_update_properties(struct pw_impl_factory *factory, const struct spa_dict *dict) { struct pw_resource *resource; int changed; changed = pw_properties_update(factory->properties, dict); factory->info.props = &factory->properties->dict; pw_log_debug("%p: updated %d properties", factory, changed); if (!changed) return 0; factory->info.change_mask |= PW_FACTORY_CHANGE_MASK_PROPS; if (factory->global) spa_list_for_each(resource, &factory->global->resource_list, link) pw_factory_resource_info(resource, &factory->info); factory->info.change_mask = 0; return changed; } SPA_EXPORT int pw_impl_factory_register(struct pw_impl_factory *factory, struct pw_properties *properties) { static const char * const keys[] = { PW_KEY_OBJECT_SERIAL, PW_KEY_MODULE_ID, PW_KEY_FACTORY_NAME, PW_KEY_FACTORY_TYPE_NAME, PW_KEY_FACTORY_TYPE_VERSION, NULL }; struct pw_context *context = factory->context; if (factory->registered) goto error_existed; factory->global = pw_global_new(context, PW_TYPE_INTERFACE_Factory, PW_VERSION_FACTORY, properties, global_bind, factory); if (factory->global == NULL) return -errno; spa_list_append(&context->factory_list, &factory->link); factory->registered = true; factory->info.id = factory->global->id; pw_properties_setf(factory->properties, PW_KEY_OBJECT_ID, "%d", factory->info.id); pw_properties_setf(factory->properties, PW_KEY_OBJECT_SERIAL, "%"PRIu64, pw_global_get_serial(factory->global)); pw_properties_set(factory->properties, PW_KEY_FACTORY_NAME, factory->info.name); pw_properties_setf(factory->properties, PW_KEY_FACTORY_TYPE_NAME, "%s", factory->info.type); pw_properties_setf(factory->properties, PW_KEY_FACTORY_TYPE_VERSION, "%d", factory->info.version); factory->info.props = &factory->properties->dict; pw_global_update_keys(factory->global, factory->info.props, keys); pw_impl_factory_emit_initialized(factory); pw_global_add_listener(factory->global, &factory->global_listener, &global_events, factory); pw_global_register(factory->global); return 0; error_existed: pw_properties_free(properties); return -EEXIST; } SPA_EXPORT void *pw_impl_factory_get_user_data(struct pw_impl_factory *factory) { return factory->user_data; } SPA_EXPORT const struct pw_factory_info *pw_impl_factory_get_info(struct pw_impl_factory *factory) { return &factory->info; } SPA_EXPORT struct pw_global *pw_impl_factory_get_global(struct pw_impl_factory *factory) { return factory->global; } SPA_EXPORT void pw_impl_factory_add_listener(struct pw_impl_factory *factory, struct spa_hook *listener, const struct pw_impl_factory_events *events, void *data) { spa_hook_list_append(&factory->listener_list, listener, events, data); } SPA_EXPORT void pw_impl_factory_set_implementation(struct pw_impl_factory *factory, const struct pw_impl_factory_implementation *implementation, void *data) { factory->impl = SPA_CALLBACKS_INIT(implementation, data); } SPA_EXPORT void *pw_impl_factory_create_object(struct pw_impl_factory *factory, struct pw_resource *resource, const char *type, uint32_t version, struct pw_properties *properties, uint32_t new_id) { void *res = NULL; spa_callbacks_call_res(&factory->impl, struct pw_impl_factory_implementation, res, create_object, 0, resource, type, version, properties, new_id); return res; } /** Find a factory by name * * \param context the context object * \param name the name of the factory to find * * Find in the list of factories registered in \a context for one with * the given \a name. * * \ingroup pw_context */ SPA_EXPORT struct pw_impl_factory *pw_context_find_factory(struct pw_context *context, const char *name) { struct pw_impl_factory *factory; spa_list_for_each(factory, &context->factory_list, link) { if (spa_streq(factory->info.name, name)) return factory; } return NULL; }
27
103
0.754476
d60bd920b1a51e159da2a81074a40fcfbb63bcfe
838
h
C
jjrms/View/AccountGrayView.h
RamboWangZJ/RMSGIT
8f896b57b51720614dd6b8824b4fe4416e3439d8
[ "Apache-2.0" ]
null
null
null
jjrms/View/AccountGrayView.h
RamboWangZJ/RMSGIT
8f896b57b51720614dd6b8824b4fe4416e3439d8
[ "Apache-2.0" ]
null
null
null
jjrms/View/AccountGrayView.h
RamboWangZJ/RMSGIT
8f896b57b51720614dd6b8824b4fe4416e3439d8
[ "Apache-2.0" ]
null
null
null
// // AccountGrayView.h // jjrms // // Created by user on 16/10/21. // Copyright © 2016年 supercity. All rights reserved. // #import <UIKit/UIKit.h> #import "UIColor+Helper.h" #import "Commen.h" #import "Masonry.h" #import "AccCheckTableViewCell.h" #import "AccCheckModel.h" #import "httpManager.h" #import "DataProcessing.h" #import "AccountsModel.h" #import "MJExtension.h" #import "NSObject+MJKeyValue.h" @interface AccountGrayView : UIView<UITableViewDelegate,UITableViewDataSource,UIGestureRecognizerDelegate> @property(nonatomic,retain)UITableView *checkTableView; @property(nonatomic,retain)NSMutableArray *checkArr; @property(nonatomic, retain)UIButton *cancel; @property(nonatomic, retain)UIButton *save; -(void)initUIDataWithUnit:(NSString *)unit Ketixian:(NSString*)ketixian; -(double)getMoney; -(NSString *)getId; @end
26.1875
106
0.770883
961584ae5eaf3d49f5ca7dbb1d61c5ca17c81603
55,755
c
C
src/lib/io/sol-iio.c
undeadinu/soletta
5ca6d6a70bead00caf154b445755be94f3f68099
[ "ECL-2.0", "Apache-2.0" ]
266
2015-06-11T00:21:02.000Z
2022-03-27T20:45:17.000Z
src/lib/io/sol-iio.c
undeadinu/soletta
5ca6d6a70bead00caf154b445755be94f3f68099
[ "ECL-2.0", "Apache-2.0" ]
2,224
2015-06-17T17:29:50.000Z
2018-07-20T23:43:40.000Z
src/lib/io/sol-iio.c
undeadinu/soletta
5ca6d6a70bead00caf154b445755be94f3f68099
[ "ECL-2.0", "Apache-2.0" ]
151
2015-06-17T14:42:54.000Z
2022-01-27T17:01:35.000Z
/* * This file is part of the Soletta (TM) Project * * Copyright (C) 2015 Intel Corporation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <ctype.h> #include <dirent.h> #include <errno.h> #include <fcntl.h> #include <glob.h> #include <limits.h> #include <stddef.h> #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <inttypes.h> #include <unistd.h> #include <sol-log.h> #include <sol-macros.h> #include <sol-mainloop.h> #include <sol-str-slice.h> #include <sol-util-internal.h> #include <sol-util-file.h> #include <sol-vector.h> #include "sol-iio.h" #ifdef USE_I2C #include <sol-i2c.h> #endif struct reader_cb_data { void (*reader_cb)(void *data, struct sol_iio_device *device); const void *data; }; struct sol_iio_device { double *mount_matrix; char *trigger_name; struct sol_vector reader_cb_list; struct sol_fd *fd_handler; struct sol_buffer buffer; size_t buffer_size; struct sol_ptr_vector channels; int device_id; int trigger_id; int fd; int name_fd; bool buffer_enabled : 1; bool manual_triggering : 1; }; struct sol_iio_channel { struct sol_iio_device *device; double scale; int index; int offset; unsigned int storagebits; unsigned int bits; unsigned int shift; unsigned int offset_in_buffer; uint64_t mask; bool little_endian : 1; bool is_signed : 1; bool processed : 1; char name[]; /* Must be last. Memory trick in place. */ }; struct resolve_name_path_data { const char *name; int id; }; struct resolve_absolute_path_data { const char *path; int id; }; struct iio_opened_device { struct sol_iio_device *device; struct sol_iio_config *config; int refcount; }; static struct sol_vector iio_opened_devices = SOL_VECTOR_INIT(struct iio_opened_device); #define DEVICE_PATH "/dev/iio:device%d" #define SYSFS_DEVICES_PATH "/sys/bus/iio/devices" #define SYSFS_DEVICE_PATH "/sys/bus/iio/devices/%s" #define CONFIGFS_IIO_HRTIMER_TRIGGERS_PATH "/sys/kernel/config/iio/triggers/hrtimer" #define CONFIGFS_IIO_HRTIMER_TRIGGER_PATH "/sys/kernel/config/iio/triggers/hrtimer/%s" #define HRTIMER_TRIGGER_PREFIX "hrtimer:" #define DEVICE_NAME_PATH SYSFS_DEVICES_PATH "/iio:device%d/name" #define DEVICE_NAME_PATH_BY_DEVICE_DIR SYSFS_DEVICES_PATH "/%s/name" #define BUFFER_ENABLE_DEVICE_PATH SYSFS_DEVICES_PATH "/iio:device%d/buffer/enable" #define BUFFER_LENGHT_DEVICE_PATH SYSFS_DEVICES_PATH "/iio:device%d/buffer/length" #define CURRENT_TRIGGER_DEVICE_PATH SYSFS_DEVICES_PATH "/iio:device%d/trigger/current_trigger" #define SYSFS_TRIGGER_NOW_PATH SYSFS_DEVICES_PATH "/%s/trigger_now" #define SYSFS_TRIGGER_NOW_BY_ID_PATH SYSFS_DEVICES_PATH "/trigger%d/trigger_now" #define SYSFS_TRIGGER_NAME_PATH SYSFS_DEVICES_PATH "/%s/name" #define SYSFS_TRIGGER_SYSFS_ADD_TRIGGER SYSFS_DEVICES_PATH "/iio_sysfs_trigger/add_trigger" #define SYSFS_TRIGGER_SYSFS_PATH SYSFS_DEVICES_PATH "/iio_sysfs_trigger" #define CHANNEL_ENABLE_PATH SYSFS_DEVICES_PATH "/iio:device%d/%s_en" #define CHANNEL_RAW_PATH SYSFS_DEVICES_PATH "/iio:device%d/%s_raw" #define CHANNEL_PROCESSED_PATH SYSFS_DEVICES_PATH "/iio:device%d/%s_input" #define CHANNEL_OFFSET_PATH SYSFS_DEVICES_PATH "/iio:device%d/%s_offset" #define CHANNEL_SCALE_PATH SYSFS_DEVICES_PATH "/iio:device%d/%s_scale" #define CHANNEL_SCAN_ENABLE_PATH SYSFS_DEVICES_PATH "/iio:device%d/scan_elements/%s_en" #define CHANNEL_SCAN_INDEX_PATH SYSFS_DEVICES_PATH "/iio:device%d/scan_elements/%s_index" #define CHANNEL_SCAN_TYPE_PATH SYSFS_DEVICES_PATH "/iio:device%d/scan_elements/%s_type" #define SAMPLING_FREQUENCY_DEVICE_PATH SYSFS_DEVICES_PATH "/iio:device%d/sampling_frequency" #define CHANNEL_SAMPLING_FREQUENCY_DEVICE_PATH SYSFS_DEVICES_PATH "/iio:device%d/%ssampling_frequency" #define CHANNEL_OVERSAMPLING_RATIO_DEVICE_PATH SYSFS_DEVICES_PATH "/iio:device%d/%soversampling_ratio" #define SAMPLING_FREQUENCY_BUFFER_PATH SYSFS_DEVICES_PATH "/iio:device%d/buffer/sampling_frequency" #define SAMPLING_FREQUENCY_TRIGGER_PATH SYSFS_DEVICES_PATH "/trigger%d/sampling_frequency" #define SYSFS_MOUNT_MATRIX SYSFS_DEVICES_PATH "/iio:device%d/mount_matrix" #define SYSFS_OUT_MOUNT_MATRIX SYSFS_DEVICES_PATH "/iio:device%d/out_mount_matrix" #define SYSFS_IN_MOUNT_MATRIX SYSFS_DEVICES_PATH "/iio:device%d/in_mount_matrix" #define I2C_DEVICES_PATH "/sys/bus/i2c/devices/%u-%04u/" #define MOUNT_MATRIX_LEN 9 #define REL_PATH_IDX 2 #define DEV_NUMBER_IDX 3 #define DEV_NAME_IDX 4 SOL_ATTR_PRINTF(3, 4) static bool craft_filename_path(char *path, size_t size, const char *base, ...) { va_list args; int len; va_start(args, base); len = vsnprintf(path, size, base, args); va_end(args); if (len < 0) path[0] = '\0'; SOL_DBG("available=%zu, used=%d, path='%s'", size, len, path); return len >= 0 && (size_t)len < size; } SOL_ATTR_PRINTF(1, 2) static bool check_file_existence(const char *base, ...) { char path[PATH_MAX]; va_list args; int len; struct stat st; va_start(args, base); len = vsnprintf(path, sizeof(path), base, args); va_end(args); return len >= 0 && (size_t)len < PATH_MAX && !stat(path, &st); } static bool check_trigger_name(const char *trigger_dir, const char *trigger_name) { char *name, path[PATH_MAX]; bool result; int len; result = craft_filename_path(path, sizeof(path), SYSFS_TRIGGER_NAME_PATH, trigger_dir); if (!result) { SOL_WRN("Could not open IIO trigger (%s) name on sysfs", trigger_dir); return false; } len = sol_util_read_file(path, "%ms", &name); if (len < 0) { SOL_WRN("Could not read IIO trigger (%s) name on sysfs", trigger_dir); return false; } result = streq(trigger_name, name); free(name); return result; } static bool check_manual_triggering(struct sol_iio_device *device) { DIR *dir; struct dirent *ent, *res; int success; long name_max; size_t len; bool result = false; /* The only way I've found to relact trigger name and trigger is * by opening all triggers on /sys/bus/iio/devices * and checking name by name =/ */ dir = opendir(SYSFS_DEVICES_PATH); if (!dir) { SOL_WRN("No IIO devices available"); return false; } /* See readdir_r(3) */ name_max = pathconf(SYSFS_DEVICES_PATH, _PC_NAME_MAX); if (name_max == -1) name_max = 255; len = offsetof(struct dirent, d_name) + name_max + 1; ent = malloc(len); SOL_NULL_CHECK_GOTO(ent, end); success = readdir_r(dir, ent, &res); while (success == 0 && res) { if (strstartswith(ent->d_name, "trigger")) { if (check_trigger_name(ent->d_name, device->trigger_name)) { /* triggers dirs are of the form triggerX, so here we save X */ device->trigger_id = atoi(ent->d_name + strlen("trigger")); device->manual_triggering = check_file_existence( SYSFS_TRIGGER_NOW_BY_ID_PATH, device->trigger_id); result = true; break; } } success = readdir_r(dir, ent, &res); } end: free(ent); closedir(dir); return result; } static bool set_current_trigger(struct sol_iio_device *device, const char *trigger_name) { char path[PATH_MAX]; bool r; r = craft_filename_path(path, sizeof(path), CURRENT_TRIGGER_DEVICE_PATH, device->device_id); if (!r) { SOL_WRN("Could not open device current_trigger file"); return false; } if (sol_util_write_file(path, "%s", trigger_name) < 0) { SOL_WRN("Could not write to device current_trigger file"); return false; } return true; } static bool create_sysfs_trigger(struct sol_iio_device *device) { int len, id, i, tries = 10; char *trigger_name; bool result = false; id = rand(); do { i = sol_util_write_file(SYSFS_TRIGGER_SYSFS_ADD_TRIGGER, "%d", id); if (i == -ENOENT) { SOL_WRN("No 'iio_sysfs_trigger' under '/sys/bus/iio/devices'." " Missing 'modprobe iio-trig-sysfs'?"); return false; } /* If EINVAL, we try again. If not, give up */ if (i < 0 && i != -EINVAL) goto error; if (i < 0) id = rand(); } while (i < 0 && tries--); if (i < 0) goto error; /* Set device current trigger */ len = asprintf(&trigger_name, "sysfstrig%d", id); if (len < 0) goto error; result = set_current_trigger(device, trigger_name); if (result) device->trigger_name = trigger_name; else { free(trigger_name); goto error; } return result; error: SOL_WRN("Could not create sysfs trigger."); return false; } static bool create_hrtimer_trigger(struct sol_iio_device *device, const char *trigger_name) { int success, id, len; bool r = false; char *name = NULL; char path[PATH_MAX]; if (check_file_existence(CONFIGFS_IIO_HRTIMER_TRIGGERS_PATH)) { if (strlen(trigger_name) == 0) { id = rand(); len = asprintf(&name, "%d", id); } else len = asprintf(&name, "%s", trigger_name); if (len < 0) goto error; r = craft_filename_path(path, sizeof(path), CONFIGFS_IIO_HRTIMER_TRIGGER_PATH, name); if (!r) { goto error; } success = mkdir(path, S_IRWXU); if (success == 0) { r = set_current_trigger(device, name); if (r) device->trigger_name = name; else { goto error; } } else { SOL_WRN("Could not create hrtimer trigger dir: %s - %s", path, sol_util_strerrora(errno)); goto error; } } else { SOL_WRN("IIO triggers folder '"CONFIGFS_IIO_HRTIMER_TRIGGERS_PATH "' does not exist."); goto error; } return r; error: free(name); SOL_WRN("Could not create hrtimer trigger."); return false; } static bool check_trigger(struct sol_iio_device *device, const struct sol_iio_config *config) { char path[PATH_MAX]; char *name = NULL; int len; bool r; r = craft_filename_path(path, sizeof(path), CURRENT_TRIGGER_DEVICE_PATH, device->device_id); if (!r) { SOL_WRN("Could not open IIO device%d trigger on sysfs", device->device_id); return false; } len = sol_util_read_file(path, "%ms", &name); if (len < 0) { if (config->trigger_name && strstartswith(config->trigger_name, HRTIMER_TRIGGER_PREFIX)) { SOL_INF("No current trigger for iio:device%d. Creating a hrtimer one.", device->device_id); if (!create_hrtimer_trigger(device, config->trigger_name + strlen(HRTIMER_TRIGGER_PREFIX))) return false; } else { SOL_INF("No current trigger for iio:device%d. Creating a sysfs one.", device->device_id); if (!create_sysfs_trigger(device)) return false; } } else device->trigger_name = name; return check_manual_triggering(device); } static void set_buffer_size(struct sol_iio_device *device, int buffer_size) { char path[PATH_MAX]; int r; if (!craft_filename_path(path, sizeof(path), BUFFER_LENGHT_DEVICE_PATH, device->device_id)) { SOL_WRN("Could not set IIO device buffer size"); return; } if ((r = sol_util_write_file(path, "%d", buffer_size)) < 0) { SOL_WRN("Could not set IIO device buffer size to %d at '%s': %s", buffer_size, path, sol_util_strerrora(-r)); } return; } static bool set_buffer_enabled(struct sol_iio_device *device, bool enabled) { char path[PATH_MAX]; bool r; r = craft_filename_path(path, sizeof(path), BUFFER_ENABLE_DEVICE_PATH, device->device_id); if (!r) return false; if (sol_util_write_file(path, "%d", enabled) < 0) return false; return true; } static bool get_buffer_value(struct sol_iio_device *device, int *value) { char path[PATH_MAX]; bool r; r = craft_filename_path(path, sizeof(path), BUFFER_ENABLE_DEVICE_PATH, device->device_id); if (!r) return false; if (sol_util_read_file(path, "%d", value) < 0) return false; return true; } static bool set_channel_enabled(struct sol_iio_device *device, const char *channel_name, bool enabled) { if (check_file_existence(CHANNEL_ENABLE_PATH, device->device_id, channel_name)) { char path[PATH_MAX]; if (!craft_filename_path(path, sizeof(path), CHANNEL_ENABLE_PATH, device->device_id, channel_name)) return false; if (sol_util_write_file(path, "%d", enabled) < 0) return false; } return true; } static size_t calc_buffer_size(const struct sol_iio_device *device) { struct sol_iio_channel *channel; int i; size_t size = 0; SOL_PTR_VECTOR_FOREACH_IDX (&device->channels, channel, i) { size += channel->storagebits; } return size / 8 + (size % 8 != 0); } static bool device_reader_cb(void *data, int fd, uint32_t active_flags) { struct sol_iio_device *device = data; struct reader_cb_data *reader_cb_data_elem = NULL; bool result = true; ssize_t ret; int i; if (active_flags & (SOL_FD_FLAGS_ERR | SOL_FD_FLAGS_HUP | SOL_FD_FLAGS_NVAL)) { SOL_WRN("Unexpected reading"); result = false; } ret = sol_util_fill_buffer(fd, &device->buffer, device->buffer_size - device->buffer.used); if (ret <= 0) { result = false; } else if (device->buffer.used == device->buffer_size) { SOL_VECTOR_FOREACH_IDX (&device->reader_cb_list, reader_cb_data_elem, i) { reader_cb_data_elem->reader_cb((void *)reader_cb_data_elem->data, device); } sol_buffer_reset(&device->buffer); } if (!result) { device->fd_handler = NULL; close(device->fd); device->fd = -1; } return result; } static bool setup_device_reader(struct sol_iio_device *device) { int fd; char path[PATH_MAX]; bool r; r = craft_filename_path(path, sizeof(path), DEVICE_PATH, device->device_id); if (!r) { SOL_WRN("Could not open IIO device%d: Could not find it's file name", device->device_id); return false; } fd = open(path, O_RDONLY | O_CLOEXEC | O_NONBLOCK); if (fd < 0) { SOL_WRN("Could not open IIO device%d: Could not access it at %s : %s", device->device_id, path, sol_util_strerrora(errno)); return false; } device->fd_handler = sol_fd_add(fd, SOL_FD_FLAGS_IN | SOL_FD_FLAGS_PRI | SOL_FD_FLAGS_ERR, device_reader_cb, device); if (!device->fd_handler) { SOL_WRN("Could not setup reader for device%d", device->device_id); close(fd); return false; } device->fd = fd; return true; } /* Some channels are named on the form <type>[_x|_y|_z] * This function shall return the name without <x|y|z> components. * And remove both/ir/uv suffix frome some light internsity sensors. * The form <type>[Y][_modifier] is also common (Y is a number), and this function * remove numbers too, in an attempt to get the 'pure' name. * TODO there are other esoteric combinations - for them, if we care about, * we will probably need API calls to get the 'scale' and 'offset' file names */ static char * channel_get_pure_name(const char *name) { char channel_name[NAME_MAX]; size_t channel_name_len; char *channel_pure_name; bool modified = false; SOL_NULL_CHECK(name, NULL); strncpy(channel_name, name, sizeof(channel_name) - 1); channel_name[sizeof(channel_name) - 1] = '\0'; channel_name_len = strlen(channel_name); if (strendswith(channel_name, "_green")) { channel_name[channel_name_len - 6] = '\0'; modified = true; } if (strendswith(channel_name, "_both") || strendswith(channel_name, "_blue")) { channel_name[channel_name_len - 5] = '\0'; modified = true; } if (strendswith(channel_name, "_red")) { channel_name[channel_name_len - 4] = '\0'; modified = true; } if (strendswith(channel_name, "_ir") || strendswith(channel_name, "_uv")) { channel_name[channel_name_len - 3] = '\0'; modified = true; } channel_name_len = strlen(channel_name); if (channel_name_len > 2) { char *channel_name_suffix; channel_name_suffix = channel_name + channel_name_len - 2; if (streq(channel_name_suffix, "_x") || streq(channel_name_suffix, "_y") || streq(channel_name_suffix, "_z")) { channel_pure_name = strndup(channel_name, channel_name_len - 2); SOL_NULL_CHECK(channel_pure_name, NULL); return channel_pure_name; } else { /* Recreate channel name without Y_ components (Y is a number). * Idea is 's/[0-9]+//' */ size_t i; char *original_channel_pure_name; channel_pure_name = calloc(1, channel_name_len + 1); SOL_NULL_CHECK(channel_pure_name, NULL); original_channel_pure_name = channel_pure_name; for (i = 0; i < channel_name_len; i++) { if (isalpha((uint8_t)channel_name[i]) || channel_name[i] == '-' || channel_name[i] == '_') *channel_pure_name++ = channel_name[i]; else if (isdigit((uint8_t)channel_name[i])) { modified = true; continue; } } if (modified) return original_channel_pure_name; free(original_channel_pure_name); return NULL; } } if (modified) { channel_pure_name = strndup(channel_name, channel_name_len); SOL_NULL_CHECK(channel_pure_name, NULL); return channel_pure_name; } return NULL; } static bool iio_set_oversampling_ratio(struct sol_iio_device *device, const struct sol_iio_config *config) { char path[PATH_MAX]; struct sol_str_table *iter; SOL_NULL_CHECK(device, false); for (iter = config->oversampling_ratio_table; iter->key; iter++) { if (!iter->val) continue; if (!craft_filename_path(path, sizeof(path), CHANNEL_OVERSAMPLING_RATIO_DEVICE_PATH, device->device_id, iter->key)) { SOL_WRN("Could not set oversampling ratio"); return false; } if (sol_util_write_file(path, "%d", iter->val) <= 0) { SOL_WRN("Could not set oversampling ratio to %d at '%s'", iter->val, path); return false; } } return true; } static bool iio_set_sampling_frequency(struct sol_iio_device *device, const struct sol_iio_config *config) { char path[PATH_MAX]; int frequency = config->sampling_frequency; SOL_NULL_CHECK(device, false); if (craft_filename_path(path, sizeof(path), SAMPLING_FREQUENCY_DEVICE_PATH, device->device_id)) { if (sol_util_write_file(path, "%d", frequency) > 0) return true; } if (craft_filename_path(path, sizeof(path), CHANNEL_SAMPLING_FREQUENCY_DEVICE_PATH, device->device_id, config->sampling_frequency_name)) { if (sol_util_write_file(path, "%d", frequency) > 0) return true; } if (craft_filename_path(path, sizeof(path), SAMPLING_FREQUENCY_BUFFER_PATH, device->device_id)) { if (sol_util_write_file(path, "%d", frequency) > 0) return true; } if (craft_filename_path(path, sizeof(path), SAMPLING_FREQUENCY_TRIGGER_PATH, device->trigger_id)) { if (sol_util_write_file(path, "%d", frequency) > 0) return true; } return false; } static bool iio_set_channel_scale(struct sol_iio_channel *channel, double scale) { char path[PATH_MAX], *pure_name = NULL; bool result = false; SOL_NULL_CHECK(channel, false); if (craft_filename_path(path, sizeof(path), CHANNEL_SCALE_PATH, channel->device->device_id, channel->name)) { if (sol_util_write_file(path, "%.9lf", scale) > 0) { channel->scale = scale; return true; } } /* If failed, try channel pure name */ pure_name = channel_get_pure_name(channel->name); if (pure_name && craft_filename_path(path, sizeof(path), CHANNEL_SCALE_PATH, channel->device->device_id, pure_name)) { result = (sol_util_write_file(path, "%.9lf", scale) > 0); if (result) channel->scale = scale; } if (!result) SOL_WRN("Could not set scale to %.9lf on channel [%s] of device%d", scale, channel->name, channel->device->device_id); free(pure_name); return result; } static bool iio_set_channel_offset(struct sol_iio_channel *channel, int offset) { char path[PATH_MAX], *pure_name = NULL; bool result = false; SOL_NULL_CHECK(channel, false); if (craft_filename_path(path, sizeof(path), CHANNEL_OFFSET_PATH, channel->device->device_id, channel->name)) { if (sol_util_write_file(path, "%d", offset) > 0) { channel->offset = offset; return true; } } /* If failed, try channel pure name */ pure_name = channel_get_pure_name(channel->name); if (pure_name && craft_filename_path(path, sizeof(path), CHANNEL_OFFSET_PATH, channel->device->device_id, pure_name)) { result = sol_util_write_file(path, "%d", offset) > 0; if (result) channel->offset = offset; } if (!result) SOL_WRN("Could not set offset to %d on channel [%s] of device%d", offset, channel->name, channel->device->device_id); free(pure_name); return result; } static bool get_mount_matrix(struct sol_iio_device *device, double *mount_matrix) { char buf[100]; char *tmp1, *tmp2; char path[PATH_MAX]; bool result = false; int len, i; double d; const char *base = NULL; /* Find the mount matrix sysfs node */ if (check_file_existence(SYSFS_MOUNT_MATRIX, device->device_id)) base = SYSFS_MOUNT_MATRIX; else if (check_file_existence(SYSFS_OUT_MOUNT_MATRIX, device->device_id)) base = SYSFS_OUT_MOUNT_MATRIX; else if (check_file_existence(SYSFS_IN_MOUNT_MATRIX, device->device_id)) base = SYSFS_IN_MOUNT_MATRIX; else { SOL_DBG("Could not find mount_matrix for device%d", device->device_id); return false; } #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" result = craft_filename_path(path, sizeof(path), base, device->device_id); #pragma GCC diagnostic pop if (!result) { SOL_WRN("Could not open device mount_matrix file"); return false; } len = sol_util_read_file(path, "%99[^\n]", buf); if (len < 0) { SOL_WRN("Coult not read mount matrix %s on sysfs.", path); return false; } SOL_DBG("in_mount_matrix=%s", buf); tmp1 = buf; for (i = 0; i < MOUNT_MATRIX_LEN; i++) { d = strtod(tmp1, &tmp2); if (tmp1 == tmp2) return false; mount_matrix[i] = d; tmp1 = tmp2 + 1; SOL_DBG("matrix[%d]=%f", i, mount_matrix[i]); } return result; } SOL_API struct sol_iio_device * sol_iio_open(int device_id, const struct sol_iio_config *config) { int i; int prefix_len = strlen(HRTIMER_TRIGGER_PREFIX); bool r; bool buffer_existence; char path[PATH_MAX]; struct sol_iio_device *device = NULL; struct iio_opened_device *entry = NULL; struct reader_cb_data *reader_cb_data_elem = NULL; SOL_NULL_CHECK(config, NULL); #ifndef SOL_NO_API_VERSION if (SOL_UNLIKELY(config->api_version != SOL_IIO_CONFIG_API_VERSION)) { SOL_WRN("IIO config version '%" PRIu16 "' is unexpected, expected '%" PRIu16 "'", config->api_version, SOL_IIO_CONFIG_API_VERSION); return NULL; } #endif SOL_VECTOR_FOREACH_IDX (&iio_opened_devices, entry, i) { if (device_id == entry->device->device_id) { if ((config->buffer_size == entry->config->buffer_size) && (config->sampling_frequency == entry->config->sampling_frequency)) { device = entry->device; reader_cb_data_elem = sol_vector_append(&device->reader_cb_list); SOL_NULL_CHECK(reader_cb_data_elem, NULL); reader_cb_data_elem->data = config->data; reader_cb_data_elem->reader_cb = config->sol_iio_reader_cb; entry->refcount++; return device; } else { SOL_ERR("device%d is already open, but could not reuse it with different config", device_id); return NULL; } } } device = calloc(1, sizeof(struct sol_iio_device)); SOL_NULL_CHECK(device, NULL); sol_ptr_vector_init(&device->channels); device->buffer = SOL_BUFFER_INIT_EMPTY; device->fd = -1; sol_vector_init(&device->reader_cb_list, sizeof(struct reader_cb_data)); device->device_id = device_id; /* Let's keep device name file open until close, so we can prevent a * rogue destruction of sysfs structure by unloading kernel module related * to it */ r = craft_filename_path(path, sizeof(path), DEVICE_NAME_PATH, device->device_id); if (!r) { SOL_WRN("Could not open IIO device%d name file", device->device_id); goto error; } device->name_fd = open(path, O_RDONLY | O_CLOEXEC); if (device->name_fd == -1) { SOL_WRN("Could not open IIO device%d name file [%s]", device->device_id, path); goto error; } buffer_existence = false; if (check_file_existence(BUFFER_ENABLE_DEVICE_PATH, device->device_id)) { buffer_existence = true; } if (config->buffer_size > -1) { if (!buffer_existence) { SOL_WRN("Buffer is enabled but device%d does not support Buffer.", device->device_id); goto error; } if (!config->sol_iio_reader_cb) { SOL_WRN("Buffer is enabled for device%d but no 'sol_iio_reader_cb'" " was defined.'", device->device_id); goto error; } reader_cb_data_elem = sol_vector_append(&device->reader_cb_list); SOL_NULL_CHECK_GOTO(reader_cb_data_elem, error); reader_cb_data_elem->reader_cb = config->sol_iio_reader_cb; reader_cb_data_elem->data = config->data; if (config->trigger_name && config->trigger_name[0] != '\0') { /* if name start with HRTIMER_TRIGGER_PREFIX, it is a hrtimer trigger */ if (strstartswith(config->trigger_name, HRTIMER_TRIGGER_PREFIX)) { if (config->trigger_name[prefix_len] != '\0') { if (!set_current_trigger(device, config->trigger_name + prefix_len)) SOL_WRN("Could not set device%d current trigger", device->device_id); } } else { if (!set_current_trigger(device, config->trigger_name)) SOL_WRN("Could not set device%d current trigger", device->device_id); } } if (!check_trigger(device, config)) { SOL_WRN("No trigger available for device%d", device->device_id); goto error; } if (config->buffer_size != 0) set_buffer_size(device, config->buffer_size); if (!device->manual_triggering) { SOL_INF("No 'trigger_now' file on device%d current trigger. " "It won't be possible to manually trigger a reading on device", device->device_id); } if (!setup_device_reader(device)) { SOL_WRN("Could not setup device%d reading", device->device_id); goto error; } device->buffer_enabled = true; } else { /* buffer_size == -1 means that user doesn't want to use the buffer */ device->buffer_enabled = false; if (buffer_existence) { if (!set_buffer_enabled(device, false)) { SOL_WRN("Could not disable buffer for device%d", device->device_id); } } } if (config->sampling_frequency > -1) { if (!iio_set_sampling_frequency(device, config)) SOL_WRN("Could not set device%d sampling frequency", device->device_id); } if (config->oversampling_ratio_table) { if (!iio_set_oversampling_ratio(device, config)) SOL_WRN("Could not set device%d oversampling ratio", device->device_id); } device->mount_matrix = calloc(MOUNT_MATRIX_LEN, sizeof(double)); SOL_NULL_CHECK_GOTO(device->mount_matrix, error); r = get_mount_matrix(device, device->mount_matrix); if (!r) { free(device->mount_matrix); device->mount_matrix = NULL; } SOL_DBG("iio device created. device%d - buffer_enabled: %d - manual_trigger: %d" " - trigger_name: %s - trigger_id: %d - mount_matrix: %p", device->device_id, device->buffer_enabled, device->manual_triggering, device->trigger_name, device->trigger_id, device->mount_matrix); entry = sol_vector_append(&iio_opened_devices); SOL_NULL_CHECK_GOTO(entry, error); entry->device = device; entry->config = calloc(1, sizeof(struct sol_iio_config)); SOL_NULL_CHECK_GOTO(entry->config, error_config); memcpy(entry->config, config, sizeof(struct sol_iio_config)); entry->refcount = 1; return device; error_config: sol_vector_del_last(&iio_opened_devices); error: sol_iio_close(device); return NULL; } static bool enable_channel_scan(struct sol_iio_channel *channel) { struct sol_iio_device *device = channel->device; char path[PATH_MAX]; int current_value, len, ret, buffer_enable; if (!craft_filename_path(path, sizeof(path), CHANNEL_SCAN_ENABLE_PATH, device->device_id, channel->name)) { return false; } /* First, check if not already enabled */ len = sol_util_read_file(path, "%d", &current_value); if (len < 0) { SOL_WRN("Could not read from %s", path); return false; } if (current_value != 1) { if (!get_buffer_value(device, &buffer_enable)) { SOL_WRN("Coult not get buffer status for device%d", device->device_id); return false; } if (buffer_enable) { if (!set_buffer_enabled(device, false)) { SOL_WRN("Could not disable buffer for device%d", device->device_id); return false; } } ret = sol_util_write_file(path, "%d", 1); if (ret < 0) { SOL_WRN("Could not enable scan %s for device%d", path, device->device_id); } if (buffer_enable) { if (!set_buffer_enabled(device, true)) { SOL_WRN("Could not enable buffer for device%d", device->device_id); return false; } } return ret > 0; } return true; } static bool read_channel_scan_info(struct sol_iio_channel *channel) { struct sol_iio_device *device = channel->device; char path[PATH_MAX]; char *type, *original_type; int len; bool crafted; crafted = craft_filename_path(path, sizeof(path), CHANNEL_SCAN_TYPE_PATH, device->device_id, channel->name); if (crafted) { len = sol_util_read_file(path, "%ms", &type); if (len < 0) return false; } else return false; original_type = type; /* Form of type is [be|le]:[s|u]bits/storagebits[>>shift] */ if (strstartswith(type, "be:")) { channel->little_endian = false; type += 3; } else if (strstartswith(type, "le:")) { channel->little_endian = true; type += 3; } else channel->little_endian = true; if (type[0] == 's') { channel->is_signed = true; type++; } else if (type[0] == 'u') { channel->is_signed = false; type++; } else channel->is_signed = true; /* TODO check if signed is the default */ len = sscanf(type, "%d/%d>>%d", &channel->bits, &channel->storagebits, &channel->shift); free(original_type); if (len == 3) { return true; } else if (len == 2) { channel->shift = 0; return true; } return false; } static int get_scale(const struct sol_iio_device *device, const char *prefix_name, double *scale) { char path[PATH_MAX]; char *pure_name = NULL; int r = 0; #define GET_SCALE(_name) \ do { \ if (craft_filename_path(path, sizeof(path), CHANNEL_SCALE_PATH, \ device->device_id, _name)) { \ r = sol_util_read_file(path, "%lf", scale); \ if (r > 0) \ goto end; \ } \ } while (0) GET_SCALE(prefix_name); pure_name = channel_get_pure_name(prefix_name); GET_SCALE(pure_name); SOL_INF("Could not get scale for channel [%s] in device%d. Assuming 1.0", prefix_name, device->device_id); *scale = 1.0; #undef GET_SCALE end: if (pure_name) free(pure_name); if (r > 0) return 0; return r; } static int channel_get_scale(struct sol_iio_channel *channel) { SOL_NULL_CHECK(channel->device, -EINVAL); SOL_NULL_CHECK(channel->name, -EINVAL); return get_scale(channel->device, channel->name, &channel->scale); } static int get_offset(const struct sol_iio_device *device, const char *prefix_name, double *offset) { char path[PATH_MAX]; char *pure_name = NULL; int r = 0; #define GET_OFFSET(_name) \ do { \ if (craft_filename_path(path, sizeof(path), CHANNEL_OFFSET_PATH, \ device->device_id, _name)) { \ r = sol_util_read_file(path, "%lf", offset); \ if (r > 0) \ goto end; \ } \ } while (0) GET_OFFSET(prefix_name); pure_name = channel_get_pure_name(prefix_name); GET_OFFSET(pure_name); SOL_INF("Could not get offset for channel [%s] in device%d. Assuming 0", prefix_name, device->device_id); *offset = 0.0; #undef GET_OFFSET end: if (pure_name) free(pure_name); if (r > 0) return 0; return r; } static int channel_get_offset(struct sol_iio_channel *channel) { SOL_NULL_CHECK(channel->device, -EINVAL); SOL_NULL_CHECK(channel->name, -EINVAL); return get_offset(channel->device, channel->name, (double *)&channel->offset); } static void iio_del_channel(struct sol_iio_device *device, struct sol_iio_channel *channel) { /* Deactivate device firmware/hardware after use */ set_channel_enabled(device, channel->name, false); free(channel); } SOL_API void sol_iio_close(struct sol_iio_device *device) { int i; struct sol_iio_channel *channel; struct iio_opened_device *entry = NULL; struct iio_opened_device *remove_entry = NULL; SOL_NULL_CHECK(device); SOL_VECTOR_FOREACH_IDX (&iio_opened_devices, entry, i) { if (device->device_id == entry->device->device_id) { entry->refcount--; if (entry->refcount == 0) { SOL_DBG("Close device%d", device->device_id); remove_entry = entry; free(entry->config); } else { SOL_DBG("Won't close device%d refcount=%d > 0", device->device_id, entry->refcount); return; } break; } } if (remove_entry) sol_vector_del_element(&iio_opened_devices, remove_entry); if (iio_opened_devices.len == 0) sol_vector_clear(&iio_opened_devices); SOL_PTR_VECTOR_FOREACH_REVERSE_IDX (&device->channels, channel, i) { iio_del_channel(device, channel); } sol_ptr_vector_clear(&device->channels); if ((device->buffer_enabled) && (!set_buffer_enabled(device, false))) SOL_WRN("Could not disable buffer for device%d", device->device_id); if (device->fd_handler) sol_fd_del(device->fd_handler); if (device->fd > -1) close(device->fd); if (device->name_fd > -1) close(device->name_fd); free(device->mount_matrix); sol_vector_clear(&device->reader_cb_list); sol_buffer_fini(&device->buffer); free(device->trigger_name); free(device); } static bool read_channel_index_in_buffer(struct sol_iio_channel *channel) { struct sol_iio_device *device = channel->device; char path[PATH_MAX]; bool r; r = craft_filename_path(path, sizeof(path), CHANNEL_SCAN_INDEX_PATH, device->device_id, channel->name); if (!r || sol_util_read_file(path, "%d", &channel->index) < 0) return false; return true; } SOL_API struct sol_iio_channel * sol_iio_add_channel(struct sol_iio_device *device, const char *name, const struct sol_iio_channel_config *config) { struct sol_iio_channel *channel; bool processed; int r; SOL_NULL_CHECK(device, NULL); SOL_NULL_CHECK(name, NULL); SOL_NULL_CHECK(config, NULL); #ifndef SOL_NO_API_VERSION if (SOL_UNLIKELY(config->api_version != SOL_IIO_CHANNEL_CONFIG_API_VERSION)) { SOL_WRN("IIO channel config version '%" PRIu16 "' is unexpected, expected '%" PRIu16 "'", config->api_version, SOL_IIO_CHANNEL_CONFIG_API_VERSION); return NULL; } #endif /* First try '_raw' suffix, then '_input' */ if (check_file_existence(CHANNEL_RAW_PATH, device->device_id, name)) processed = false; else if (check_file_existence(CHANNEL_PROCESSED_PATH, device->device_id, name)) processed = true; else { SOL_WRN("Could not find channel [%s] for device%d", name, device->device_id); return NULL; } channel = calloc(1, sizeof(struct sol_iio_channel) + strlen(name) + 1); SOL_NULL_CHECK(channel, NULL); memcpy(channel->name, name, strlen(name)); channel->device = device; channel->processed = processed; r = 0; if (config->scale > -1) r = !!iio_set_channel_scale(channel, config->scale); if (!r) channel_get_scale(channel); r = 0; if (config->use_custom_offset) r = !!iio_set_channel_offset(channel, config->offset); if (!r) channel_get_offset(channel); if (device->buffer_enabled) { if (!enable_channel_scan(channel)) { SOL_WRN("Could not enable scanning of channel [%s] in device%d", channel->name, device->device_id); goto error; } if (!read_channel_scan_info(channel)) { SOL_WRN("Could not read scanning info of channel [%s] in device%d", channel->name, device->device_id); goto error; } if (!read_channel_index_in_buffer(channel)) { SOL_WRN("Could not read index in buffer of channel [%s] in device%d", channel->name, device->device_id); goto error; } channel->mask = ((uint64_t)1 << channel->bits) - 1; } r = sol_ptr_vector_append(&channel->device->channels, channel); SOL_INT_CHECK_GOTO(r, < 0, error); /* Some device firmware/hardware feature default state is off, thus need to activate it before read */ if (!set_channel_enabled(device, name, true)) SOL_WRN("Could not activate device channel [%s] in device%d", name, device->device_id); SOL_DBG("channel [%s] added. scale: %.9lf - offset: %d - storagebits: %d" " - bits: %d - mask: %" PRIu64, channel->name, channel->scale, channel->offset, channel->storagebits, channel->bits, channel->mask); return channel; error: iio_del_channel(device, channel); return NULL; } static int iio_read_buffer_channel_value(struct sol_iio_channel *channel, double *value) { uint64_t data = 0; int64_t s_data; unsigned j, offset_bytes; int i, storage_bytes; bool negative = false; struct sol_iio_device *device = channel->device; uint8_t *buffer = device->buffer.data; SOL_NULL_CHECK(buffer, -EINVAL); if (channel->storagebits > 64) { SOL_WRN("Could not read channel [%s] value - more than 64 bits of" " storage - found %d. Use sol_iio_read_channel_raw_buffer() instead", channel->name, channel->storagebits); return -EBADMSG; } if (channel->offset_in_buffer + channel->storagebits > device->buffer_size * 8) { SOL_WRN("Invalid read on buffer."); return -EBADMSG; } offset_bytes = channel->offset_in_buffer / 8; storage_bytes = channel->storagebits / 8; if (channel->little_endian) { for (i = 0, j = 0; i < storage_bytes; i++, j += 8) { data |= (uint64_t)buffer[i + offset_bytes] << j; } } else { for (i = storage_bytes - 1, j = 0; i >= 0; i--, j += 8) { data |= (uint64_t)buffer[i + offset_bytes] << j; } } data >>= channel->shift; /* Remove the top useless bits */ data &= channel->mask; /* If signed and msb is 1, we have a negative number */ if (channel->is_signed) { negative = data & (1 << (channel->bits - 1)); } if (negative) { s_data = data | ~channel->mask; *value = s_data; } else *value = data; if (!channel->processed) *value = (*value + channel->offset) * channel->scale; return 0; } SOL_API int sol_iio_read_channel_value(struct sol_iio_channel *channel, double *value) { int len; double raw_value; char path[PATH_MAX]; struct sol_iio_device *device; bool r; SOL_NULL_CHECK(channel, -EINVAL); SOL_NULL_CHECK(value, -EINVAL); device = channel->device; if (device->buffer_enabled) { return iio_read_buffer_channel_value(channel, value); } r = craft_filename_path(path, sizeof(path), channel->processed ? CHANNEL_PROCESSED_PATH : CHANNEL_RAW_PATH, device->device_id, channel->name); if (!r) { SOL_WRN("Could not read channel [%s] in device%d", channel->name, device->device_id); return -ENOMEM; } len = sol_util_read_file(path, "%lf", &raw_value); if (len < 0) { SOL_WRN("Could not read channel [%s] in device%d", channel->name, device->device_id); return -EIO; } if (channel->processed) *value = raw_value; else *value = (raw_value + channel->offset) * channel->scale; return 0; } static int calc_channel_offset_in_buffer(const struct sol_iio_channel *channel) { struct sol_iio_channel *channel_itr; int i, offset = 0; SOL_PTR_VECTOR_FOREACH_IDX (&channel->device->channels, channel_itr, i) { if (channel_itr->index < channel->index) offset += channel->storagebits; } return offset; } SOL_API int sol_iio_device_trigger(struct sol_iio_device *device) { char path[PATH_MAX]; bool r; int i; SOL_NULL_CHECK(device, -EINVAL); if (!device->manual_triggering) { SOL_WRN("No manual triggering available for device%d", device->device_id); return -EBADF; } r = craft_filename_path(path, sizeof(path), SYSFS_TRIGGER_NOW_BY_ID_PATH, device->trigger_id); if (!r) { SOL_WRN("No valid trigger_now file available for trigger [%s]", device->trigger_name); return -EBADF; } if ((i = sol_util_write_file(path, "%d", 1)) < 0) { SOL_WRN("Could not write to trigger_now file for trigger [%s]: %s", device->trigger_name, sol_util_strerrora(i)); return -EBADF; } return 0; } SOL_API int sol_iio_device_start_buffer(struct sol_iio_device *device) { struct sol_iio_channel *channel; int i; SOL_NULL_CHECK(device, -EINVAL); /* Enable device after added all channels */ if (device->buffer_enabled && !set_buffer_enabled(device, true)) { SOL_WRN("Could not enable buffer for device. No readings will be performed"); return -EBADMSG; } device->buffer_size = calc_buffer_size(device); i = sol_buffer_ensure(&device->buffer, device->buffer_size); if (i < 0) { SOL_WRN("Could not alloc buffer for device. No readings will be performed"); return -ENOMEM; } /* Now that all channels have been added, calc their offset in buffer */ SOL_PTR_VECTOR_FOREACH_IDX (&device->channels, channel, i) { channel->offset_in_buffer = calc_channel_offset_in_buffer(channel); } return 0; } static enum sol_util_iterate_dir_reason resolve_name_path_cb(void *data, const char *dir_path, struct dirent *ent) { struct resolve_name_path_data *result = data; char path[PATH_MAX], *name; int len; if (strstartswith(ent->d_name, "iio:device")) { if (craft_filename_path(path, sizeof(path), DEVICE_NAME_PATH_BY_DEVICE_DIR, ent->d_name)) { len = sol_util_read_file(path, "%ms", &name); if (len > 0) { if (streq(name, result->name)) { result->id = atoi(ent->d_name + strlen("iio:device")); free(name); return SOL_UTIL_ITERATE_DIR_STOP; } free(name); } } } return SOL_UTIL_ITERATE_DIR_CONTINUE; } static int resolve_name_path(const char *name) { struct resolve_name_path_data data = { .id = -1, .name = name }; sol_util_iterate_dir(SYSFS_DEVICES_PATH, resolve_name_path_cb, &data); return data.id; } static enum sol_util_iterate_dir_reason resolve_absolute_path_cb(void *data, const char *dir_path, struct dirent *ent) { struct resolve_absolute_path_data *result = data; char path[PATH_MAX], real_path[PATH_MAX]; if (craft_filename_path(path, sizeof(path), SYSFS_DEVICE_PATH, ent->d_name)) { if (realpath(path, real_path)) { SOL_DBG("resolve_absolute_path_cb - Real path: %s", real_path); if (strstartswith(real_path, result->path)) { result->id = atoi(ent->d_name + strlen("iio:device")); return SOL_UTIL_ITERATE_DIR_STOP; } } } return SOL_UTIL_ITERATE_DIR_CONTINUE; } static char * resolve_path(const char *path, char *resolved_path) { int r; char *p; glob_t result; r = glob(path, GLOB_MARK | GLOB_TILDE, NULL, &result); if (r != 0) { switch (r) { case GLOB_NOMATCH: errno = ENOENT; return NULL; case GLOB_NOSPACE: errno = ENOMEM; return NULL; case GLOB_ABORTED: default: errno = EINVAL; return NULL; } } p = realpath(result.gl_pathv[0], resolved_path); globfree(&result); return p ? resolved_path : NULL; } static int resolve_absolute_path(const char *address) { char real_path[PATH_MAX]; struct resolve_absolute_path_data result = { .id = -1 }; struct timespec start = sol_util_timespec_get_current(); /* Wait up to one second for the file to exist. Useful if we created * via i2c */ SOL_DBG("Trying to open address: %s", address); while (result.id == -1) { struct timespec elapsed, now; if (resolve_path(address, real_path)) { result.path = real_path; SOL_DBG("resolve_absolute_path - Real path: %s", real_path); sol_util_iterate_dir(SYSFS_DEVICES_PATH, resolve_absolute_path_cb, &result); } now = sol_util_timespec_get_current(); sol_util_timespec_sub(&now, &start, &elapsed); if (elapsed.tv_sec > 0) break; } return result.id; } static int resolve_i2c_path(const char *address) { unsigned int bus, device; char path[PATH_MAX], real_path[PATH_MAX]; struct resolve_absolute_path_data result = { .id = -1 }; if (sscanf(address, "%u-%u", &bus, &device) != 2) { SOL_WRN("Unexpected i2c address format. Got [%s], expected X-YYYY," " where X is bus number and YYYY is device address", address); return -1; } if (craft_filename_path(path, sizeof(path), I2C_DEVICES_PATH, bus, device)) { /* Idea: check if there's a symbolic link on iio/devices to the same * destination as the i2c dir */ if (realpath(path, real_path)) { result.path = real_path; sol_util_iterate_dir(SYSFS_DEVICES_PATH, resolve_absolute_path_cb, &result); } } return result.id; } static int check_device_id(int id) { char path[PATH_MAX]; struct stat st; if (craft_filename_path(path, sizeof(path), DEVICE_NAME_PATH, id)) { if (!stat(path, &st)) return id; } return -1; } static int resolve_device_address(const char *address) { char *end_ptr; int i; SOL_NULL_CHECK(address, -1); if (strstartswith(address, "/")) return resolve_absolute_path(address); if (strstartswith(address, "i2c/")) return resolve_i2c_path(address + strlen("i2c/")); errno = 0; i = strtol(address, &end_ptr, 0); if (!errno && *end_ptr == '\0') return check_device_id(i); return resolve_name_path(address); } static char * create_device_address(struct sol_str_slice *command) { char *rel_path = NULL, *dev_number_s = NULL, *dev_name = NULL, *result = NULL; struct sol_vector instructions = SOL_VECTOR_INIT(struct sol_str_slice); struct sol_buffer path = SOL_BUFFER_INIT_EMPTY; if (strstartswith(command->data, "create,i2c,")) { #ifndef USE_I2C SOL_WRN("No support for i2c"); goto end; #else unsigned int dev_number; char *end_ptr; int r; instructions = sol_str_slice_split(*command, ",", 5); if (instructions.len < 5) { SOL_WRN("Invalid create device path. Expected 'create,i2c,<rel_path>," "<devnumber>,<devname>'"); goto end; } rel_path = sol_str_slice_to_str( *(const struct sol_str_slice *)sol_vector_get(&instructions, REL_PATH_IDX)); SOL_NULL_CHECK_GOTO(rel_path, end); dev_number_s = sol_str_slice_to_str( *(const struct sol_str_slice *)sol_vector_get(&instructions, DEV_NUMBER_IDX)); SOL_NULL_CHECK_GOTO(dev_number_s, end); errno = 0; dev_number = strtoul(dev_number_s, &end_ptr, 0); if (errno || *end_ptr != '\0') goto end; dev_name = sol_str_slice_to_str( *(const struct sol_str_slice *)sol_vector_get(&instructions, DEV_NAME_IDX)); SOL_NULL_CHECK_GOTO(dev_name, end); r = sol_i2c_create_device(rel_path, dev_name, dev_number, &path); if (r >= 0 || r == -EEXIST) result = sol_buffer_steal(&path, NULL); #endif } end: free(rel_path); free(dev_number_s); free(dev_name); sol_vector_clear(&instructions); sol_buffer_fini(&path); return result; } SOL_API int sol_iio_address_device(const char *commands) { struct sol_vector commands_vector; struct sol_str_slice *command; char *command_s; int r = -1, command_index = 0; SOL_NULL_CHECK(commands, -EINVAL); commands_vector = sol_str_slice_split(sol_str_slice_from_str(commands), " ", 0); do { command = sol_vector_get(&commands_vector, command_index++); if (!command) { SOL_WRN("Could not create or resolve device address using any of commands"); r = -EINVAL; goto end; } SOL_DBG("IIO device creation/resolving dispatching command: %.*s", SOL_STR_SLICE_PRINT(*command)); if (strstartswith(command->data, "create,")) command_s = create_device_address(command); else command_s = sol_str_slice_to_str(*command); if (command_s) { r = resolve_device_address(command_s); free(command_s); } } while (r < 0); end: sol_vector_clear(&commands_vector); return r; } SOL_API struct sol_str_slice sol_iio_read_channel_raw_buffer(struct sol_iio_channel *channel) { struct sol_str_slice slice = SOL_STR_SLICE_EMPTY; unsigned int offset_bytes, storage_bytes; SOL_NULL_CHECK(channel, slice); SOL_NULL_CHECK(channel->device->buffer.data, slice); if (!channel->device->buffer_enabled) { SOL_WRN("sol_iio_read_channel_raw_buffer() only works when buffer" " is enabled."); return slice; } offset_bytes = channel->offset_in_buffer / 8; storage_bytes = channel->storagebits / 8; slice.len = storage_bytes; slice.data = (char *)channel->device->buffer.data + offset_bytes; return slice; } SOL_API int sol_iio_mount_calibration(struct sol_iio_device *device, sol_direction_vector *value) { int i; double tmp[3]; if (!device->mount_matrix) return -1; // mount correction for (i = 0; i < 3; i++) { tmp[i] = value->x * device->mount_matrix[i * 3] + value->y * device->mount_matrix[i * 3 + 1] + value->z * device->mount_matrix[i * 3 + 2]; } value->x = tmp[0]; value->y = tmp[1]; value->z = tmp[2]; SOL_DBG("%f-%f-%f", value->x, value->y, value->z); return 0; } SOL_API const char * sol_iio_channel_get_name(const struct sol_iio_channel *channel) { SOL_NULL_CHECK(channel, NULL); return channel->name; } SOL_API int sol_iio_device_get_scale(const struct sol_iio_device *device, const char *prefix_name, double *scale) { SOL_NULL_CHECK(device, -EINVAL); SOL_NULL_CHECK(prefix_name, -EINVAL); SOL_NULL_CHECK(scale, -EINVAL); return get_scale(device, prefix_name, scale); } SOL_API int sol_iio_device_get_offset(const struct sol_iio_device *device, const char *prefix_name, double *offset) { SOL_NULL_CHECK(device, -EINVAL); SOL_NULL_CHECK(prefix_name, -EINVAL); SOL_NULL_CHECK(offset, -EINVAL); return get_offset(device, prefix_name, offset); } SOL_API int sol_iio_device_get_sampling_frequency(const struct sol_iio_device *device, const char *prefix_name, int *sampling_frequency) { char path[PATH_MAX]; int r; SOL_NULL_CHECK(device, -EINVAL); SOL_NULL_CHECK(prefix_name, -EINVAL); SOL_NULL_CHECK(sampling_frequency, -EINVAL); if (craft_filename_path(path, sizeof(path), CHANNEL_SAMPLING_FREQUENCY_DEVICE_PATH, device->device_id, prefix_name)) { r = sol_util_read_file(path, "%d", sampling_frequency); SOL_INT_CHECK(r, < 0, r); } if (craft_filename_path(path, sizeof(path), SAMPLING_FREQUENCY_DEVICE_PATH, device->device_id)) { r = sol_util_read_file(path, "%d", sampling_frequency); SOL_INT_CHECK(r, < 0, r); } return 0; }
28.888601
124
0.633414