Category Python Modules

Modules is one of the best feature of Python. Except some core modules, you can install what you need and keep your Python setup smooth.

A Practical Guide to scipy.integrate.solve_ivp

Featured Image For: A Practical Guide To Scipy Integrate Solve Ivp

I keep needing to simulate things that change over time – population decay, chemical reactions, mechanical systems. My first instinct was to reach for a hand-rolled Euler method, but that breaks down fast once the system gets even slightly complex.…

Tkinter GUI Widgets

Tkinter GUI Widgets

Tkinter is Python’s standard GUI library. It ships with every Python installation, requires no separate installation, and provides enough widgets to build real desktop applications. This guide walks through the most commonly used Tkinter widgets, with working examples you can…

`;e.insertAdjacentHTML(n,i)}return document.getElementById(t)}_repeatDynamicAds(e){let t=[],n=e.location===D.Recipe?99:this.locationMaxLazySequence.get(e.location),r=e.lazy?L(n,0):0,i=e.max,a=e.lazyMax,o=r===0&&e.lazy?i+a:Math.min(Math.max(r-e.sequence+1,0),i+a),s=Math.max(i,o);for(let n=0;n=i,o=r;e.name===`Recipe_1`&&r>=5&&(o=r+1),t.push(R(R({},e),{},{sequence:o,lazy:a}))}return t}_locationEnabled(e){let t=this._clsOptions.enabledLocations.includes(e.location),n=this._clsOptions.disableAds&&this._clsOptions.disableAds.all||document.body.classList.contains(`adthrive-disable-all`),r=!document.body.classList.contains(`adthrive-disable-content`)&&!this._clsOptions.disableAds.reasons.has(`content_plugin`);return t&&!n&&r}},Hn=class{constructor(){k(this,`_map`,[])}add(e,t,n,r=document){this._map.push({el:e,coords:t,dynamicAd:n,target:r})}addSorted(e,t,n,r=document){let i=this._upperBoundIndex(t);this._map.splice(i,0,{el:e,coords:t,dynamicAd:n,target:r})}get map(){return this._map}sort(){this._map.sort(({coords:e},{coords:t})=>e-t)}filterUsed(){this._map=this._map.filter(({dynamicAd:e})=>!e.used)}findNeighborIndices(e){let t=this._upperBoundIndex(e);return[t-1>=0?t-1:null,t>>1;this._map[r].coords<=e?t=r+1:n=r}return t}reset(){this._map=[]}},Un=class extends Hn{};let Wn=e=>{let t=st(),n=ft(),r=e.siteAdsProfiles,i=null;if(r&&r.length)for(let e of r){let r=e.targeting.device,a=e.targeting.browserEngine,o=r&&r.length&&r.includes(n),s=a&&a.length&&a.includes(t);o&&s&&(i=e)}return i},Gn=e=>{let t=Wn(e);if(t){let e=t.profileId;document.body.classList.add(`raptive-profile-${e}`)}},$={Video_Collapse_Autoplay_SoundOff:`Video_Collapse_Autoplay_SoundOff`,Video_Individual_Autoplay_SOff:`Video_Individual_Autoplay_SOff`,Video_Coll_SOff_Smartphone:`Video_Coll_SOff_Smartphone`,Video_In_Post_ClicktoPlay_SoundOn:`Video_In-Post_ClicktoPlay_SoundOn`,Video_Collapse_Autoplay_SoundOff_15s:`Video_Collapse_Autoplay_SoundOff_15s`,Video_Individual_Autoplay_SOff_15s:`Video_Individual_Autoplay_SOff_15s`,Video_Coll_SOff_Smartphone_15s:`Video_Coll_SOff_Smartphone_15s`,Video_In_Post_ClicktoPlay_SoundOn_15s:`Video_In-Post_ClicktoPlay_SoundOn_15s`};var Kn=class{get enabled(){throw Error(`Enablement must be defined at factory creation time.`)}};let qn=(e=navigator.userAgent)=>_t(e)===`desktop`;function Jn(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function Yn(e,t){if(e==null)return{};var n,r,i=Jn(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;re.type===`stationaryRelated`&&e.enabled&&n.add(e)),[...n]}_filterPlayerMap(){let e=this._videoConfig.players,t={stickyRelated:[],stickyPlaylist:[],stationaryRelated:[]};return e&&e.length?e.filter(e=>{var t;return(t=e.devices)==null?void 0:t.includes(this._device)}).reduce((e,t)=>{if(e[t.type]||(B.event(this._component,`constructor`,`Unknown Video Player Type detected`,t.type),e[t.type]=[]),t.enabled){let n=t.type;this._videoConfig.shouldDisableStickyRelated&&t.type===`stickyRelated`&&(n=`stationaryRelated`),e[n].push(t)}return e},t):t}_checkPlayerSelectorOnPage(e){for(let t of this._potentialPlayerMap[e]){let e=this._getPlacementElement(t);if(e)return{player:t,playerElement:e}}return{player:null,playerElement:null}}_getOverrideElement(e,t,n){if(e&&t){let r=document.createElement(`div`);t.insertAdjacentElement(e.position,r),n=r}else{let{player:e,playerElement:t}=this._checkPlayerSelectorOnPage(`stickyPlaylist`);if(e&&t){let r=document.createElement(`div`);t.insertAdjacentElement(e.position,r),n=r}}return n}_shouldOverrideElement(e){let t=e.getAttribute(`override-embed`);return t===`true`||t===`false`?t===`true`:this._videoConfig.relatedSettings?this._videoConfig.relatedSettings.overrideEmbedLocation:!1}_checkPageSelector(e,t,n=[]){return e&&t&&n.length===0?(window.location.pathname!==`/`&&B.event(`VideoUtils`,`getPlacementElement`,Error(`PSNF: ${e} does not exist on the page`)),!1):!0}_getElementSelector(e,t,n){return t&&t.length>n?t[n]:(B.event(`VideoUtils`,`getPlacementElement`,Error(`ESNF: ${e} does not exist on the page`)),null)}_getPlacementElement(e){let{pageSelector:t,elementSelector:n,skip:r}=e,i=Et(t),{valid:a,elements:o}=i,s=Yn(i,Xn),c=Tt(n),{valid:l,elements:u}=c,d=Yn(c,Zn);return t!==``&&!a?(B.error(`VideoUtils`,`getPlacementElement`,Error(`${t} is not a valid selector`),s),null):l?this._checkPageSelector(t,a,o)&&this._getElementSelector(n,u,r)||null:(B.error(`VideoUtils`,`getPlacementElement`,Error(`${n} is not a valid selector`),d),null)}_getEmbeddedPlayerType(e){if(this._videoConfig.shouldDisableStickyRelated)return`static`;let t=e.getAttribute(`data-player-type`);return(!t||t===`default`)&&(t=this._videoConfig.relatedSettings?this._videoConfig.relatedSettings.defaultPlayerType:`static`),this._stickyRelatedOnPage&&(t=`static`),t}_getMediaId(e){let t=e.getAttribute(`data-video-id`);return t?(this._relatedMediaIds.push(t),t):!1}_getOrientation(e){return e.getAttribute(`orientation`)===`vertical`?`vertical`:`horizontal`}_createRelatedPlayer(e,t,n,r,i){t===`collapse`?this._createCollapsePlayer(e,n):t===`static`&&this._createStaticPlayer(e,n,r,i)}_createCollapsePlayer(e,t){let{player:n,playerElement:r}=this._checkPlayerSelectorOnPage(`stickyRelated`),i=n||this._potentialPlayerMap.stationaryRelated[0];i&&i.playerId&&!this._videoConfig.shouldDisableStickyRelated?(this._shouldOverrideElement(t)&&(t=this._getOverrideElement(n,r,t)),t=document.querySelector(`#cls-video-container-${e} > div`)||t,this._createStickyRelatedPlayer(R(R({},i),{},{mediaId:e}),t)):B.error(this._component,`_createCollapsePlayer`,`No video player found`)}_createStaticPlayer(e,t,n,r){if(this._potentialPlayerMap.stationaryRelated.length&&this._potentialPlayerMap.stationaryRelated[0].playerId){let i=this._potentialPlayerMap.stationaryRelated[0];this._createStationaryRelatedPlayer(R(R({},i),{},{mediaOrPlaylistId:e,orientation:r}),t,n)}else B.error(this._component,`_createStaticPlayer`,`No video player found`)}_shouldRunAutoplayPlayers(){return!!(this._isVideoAllowedOnPage()&&(this._potentialPlayerMap.stickyRelated.length||this._potentialPlayerMap.stickyPlaylist.length))}_setPlaylistMediaIdWhenStationaryOnPage(e,t){if(this._potentialPlayerMap.stationaryRelated.length&&this._potentialPlayerMap.stationaryRelated[0].playerId&&e&&e.length){let n=e[0].getAttribute(`data-video-id`);return n?R(R({},t),{},{mediaId:n}):t}return t}_determineAutoplayPlayers(e){let t=this._component,n=t===`VideoManagerComponent`,r=this._context;if(this._stickyRelatedOnPage){B.event(t,`stickyRelatedOnPage`,n&&{device:r&&r.device,isDesktop:this._device}||{});return}let{playerElement:i}=this._checkPlayerSelectorOnPage(`stickyPlaylist`),{player:a}=this._checkPlayerSelectorOnPage(`stickyPlaylist`);a&&a.playerId&&i?(a=this._setPlaylistMediaIdWhenStationaryOnPage(e,a),this._createPlaylistPlayer(a,i)):Math.random()<.01&&setTimeout(()=>{B.event(t,`noStickyPlaylist`,n&&{vendor:`none`,device:r&&r.device,isDesktop:this._device}||{})},1e3)}_initializeRelatedPlayers(e){let t=new Map;for(let n=0;n{let e=new qe;!e||!e.enabled||(e.siteAds&&Gn(e.siteAds),new Vn(e,new Un).start(),new $n(new bt(e),e).init())})()}catch(e){B.error(`CLS`,`pluginsertion-iife`,e),window.adthriveCLS&&(window.adthriveCLS.injectedFromPlugin=!1)}})();