diff --git a/.gitignore b/.gitignore index b97131e..ef9a474 100644 --- a/.gitignore +++ b/.gitignore @@ -129,3 +129,6 @@ dmypy.json .pyre/ .idea/ + +# Generated by Mac Finder +.DS_Store \ No newline at end of file diff --git a/documentation/Makefile b/documentation/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/documentation/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/documentation/make.bat b/documentation/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/documentation/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/documentation/source/conf.py b/documentation/source/conf.py new file mode 100644 index 0000000..a53d985 --- /dev/null +++ b/documentation/source/conf.py @@ -0,0 +1,31 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'Causaleffectpy Documentation' +copyright = '2024, Haley Hummel' +author = 'Haley Hummel' +release = '0.0.1' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + # other extensions + 'sphinx_rtd_theme', +] + +templates_path = ['_templates'] +exclude_patterns = [] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'sphinx_rtd_theme' +html_static_path = ['_static'] diff --git a/documentation/source/functions.rst b/documentation/source/functions.rst new file mode 100644 index 0000000..09b778d --- /dev/null +++ b/documentation/source/functions.rst @@ -0,0 +1,11 @@ +Causaleffectpy Functions +======================= + +.. toctree:: + :maxdepth: 4 + :titlesonly: + + simplify + join + insert + powerset diff --git a/documentation/source/index.rst b/documentation/source/index.rst new file mode 100644 index 0000000..cfa8c44 --- /dev/null +++ b/documentation/source/index.rst @@ -0,0 +1,30 @@ +.. Causaleffectpy documentation master file, created by + sphinx-quickstart on Tue Aug 13 12:31:43 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +`Causaleffectpy` Documentation +========================== + +This documentation provides an overview of `causaleffectpy`, which is derived from Santu Tikka's `causaleffect` R package. This documentation will focus on `simplify` and related functions in order to integrate them into the open source `y0` (Why Not?) Python package. For further information, see Tikka & Karvanen (2017) "Simplifying Probabilistic Expressions in Causal Inference". + +.. toctree:: + :maxdepth: 2 + + functions + + +References +=============== + +Hoyt, C.T., Zucker, J., & Parent, M-A. (2021). Y0 “Why Not?” for Causal Inference in Python (1.0) [Python package]. 10.5281/zenodo.4950768. https://github.com/y0-causal-inference/y0. +Tikka, S. (2022). causaleffect: Deriving Expressions of Joint Interventional Distributions and Transport Formulas in Causal Models (1.3.15) [R package]. https://github.com/santikka/causaleffect/. +Tikka, S., & Karvanen, J. (2017). Simplifying probabilistic expressions in causal inference. Journal of Machine Learning Research, 18(36), 1-30. + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` \ No newline at end of file diff --git a/documentation/source/insert.rst b/documentation/source/insert.rst new file mode 100644 index 0000000..286ec36 --- /dev/null +++ b/documentation/source/insert.rst @@ -0,0 +1,73 @@ +Insert +====== + +The `Insert` function inserts a missing variable into a joint distribution :math:`P(J|D)` using d-separation criteria in a given graph `G`. It is called when there are variables without corresponding terms in the expression. + +Parameters +---------- +joint_dist_variables : list of str + Equivalent to `J` in Tikka's `causaleffect` R package. + Existing joint set :math:`P(J|D)`; already processed and included in the joint distribution + from previous `simplify` iteration. Initially, may be empty for the starting point of + the joint distribution. `new_variable` is added to expand it using `insert` if d-separation conditions are met. +joint_conditioning_set : list of str + Equivalent to `D` in Tikka's `causaleffect` R package. Represented by the term :math:`P(V|C) := P(V_k|C_k)` in Tikka & Karvanen (2017). + Conditioning set for the already existing joint distribution :math:`P(J|D)`, used to condition the joint distribution over the set `joint_dist_variables`. + As `join` iterates, `conditioning_set` is modified to determine how the joint distribution :math:`P(J|D)` can be updated to + include the new variable `new_variable`, while preserving the required conditional independencies. +inserted_variables : str + Equivalent to `M` in Tikka's `causaleffect` R package. + Missing variables (variables not contained within the expression). +prob_conditioning_set : list of str + Equivalent to `cond` in Tikka's `causaleffect` R package. + Conditioning set for the current probabilistic term P(vari|cond); the set of variables that condition the current variable `new_variable`. + `join` uses `prob_conditioning_set` to evaluate conditional independence and determine if `new_variable` can be added to `joint_dist_variables`. +summation_variables : list of str + Equivalent to `S` in Tikka's `causaleffect` R package. + Not used directly in `join`. Current summation variable. +observed_variables : list of str + Equivalent to `O` in Tikka's `causaleffect` R package. + Observed variables (variables contained within the expression). +G_unobs : y0.Graph + Separate graph that turns bidirected edges into explicit nodes for unobserved confounders. +G : y0.Graph + Main graph `G`. Includes bidirected edges. +G_obs : y0.Graph + Separate graph that does not contain bidirected edges (only contains the directed edges with observed nodes). +topo : list of str + The topological ordering of the vertices in graph `G`. + +Returns +------- +Section in-progress + + +Examples +-------- +Section in-progress +.. code-block:: python + + +See Also +-------- +- :func:`join` +- :func:`simplify` +- :func:`is_d_separated` +- :func:`powerset` + +Keywords +-------- +models, manip, math, utilities, graphs, methods, multivariate, distribution, probability + +Concepts +-------- +probabilistic expressions, graph theory, joint distribution, causal inference, d-separation + +References +---------- +Tikka, S., & Karvanen, J. (2017). Simplifying probabilistic expressions in causal inference. *Journal of Machine Learning Research*, 18(36), 1-30. + +Author +------ +Haley Hummel, +Psychology PhD student at Oregon State University \ No newline at end of file diff --git a/documentation/source/join.rst b/documentation/source/join.rst new file mode 100644 index 0000000..d9f3017 --- /dev/null +++ b/documentation/source/join.rst @@ -0,0 +1,91 @@ +Join +==== + +The `join` function determines whether the terms of the atomic expression actually represent a joint distribution. +It attempts to combine two terms: the joint term :math:`P(J|D)` obtained from `simplify()` and the term :math:`P(V|C) := P(V_k|C_k)` +of the current iteration step. `join` iterates over potential subsets to find a valid set where the variable `new_variable` +can be added to the joint distribution `joint_dist_variables`. During this process, `join` checks conditional +independencies using both `joint_conditioning_set` and `prob_conditioning_set`. The goal is to determine if these +terms can be combined based on the d-separation criteria in the graph `G`. + +Parameters +---------- +joint_dist_variables : list of str + Equivalent to `J` in Tikka's `causaleffect` R package. + Existing joint set :math:`P(J|D)`; already processed and included in the joint distribution + from previous `simplify` iteration. Initially, may be empty for the starting point of + the joint distribution. `new_variable` is added to expand it using `insert` if d-separation conditions are met. +joint_conditioning_set : list of str + Equivalent to `D` in Tikka's `causaleffect` R package. Represented by the term :math:`P(V|C) := P(V_k|C_k)` in Tikka & Karvanen (2017). + Conditioning set for the already existing joint distribution :math:`P(J|D)`, used to condition the joint distribution over the set `joint_dist_variables`. + As `join` iterates, `conditioning_set` is modified to determine how the joint distribution :math:`P(J|D)` can be updated to + include the new variable `new_variable`, while preserving the required conditional independencies. +new_variable : str + Equivalent to `vari` in Tikka's `causaleffect` R package. + New variable being considered for inclusion in the joint distribution (the new variable that we may want to add to the joint distribution `joint_dist_variables`). + `join` attempts to update the joint distribution `joint_dist_variables` by adding `new_variable` to define a new probabilistic term if the term still + satisfies the required conditional independencies. `insert` adds `new_variable` to `joint_dist_variables`. +prob_conditioning_set : list of str + Equivalent to `cond` in Tikka's `causaleffect` R package. + Conditioning set for the current probabilistic term P(vari|cond); the set of variables that condition the current variable `new_variable`. + `join` uses `prob_conditioning_set` to evaluate conditional independence and determine if `new_variable` can be added to `joint_dist_variables`. +summation_variables : list of str + Equivalent to `S` in Tikka's `causaleffect` R package. + Not used directly in `join`. Current summation variable. +inserted_variables : list of str + Equivalent to `M` in Tikka's `causaleffect` R package. + Missing variables (variables not contained within the expression). +observed_variables : list of str + Equivalent to `O` in Tikka's `causaleffect` R package. + Observed variables (variables contained within the expression). +G_unobs : `networkx.DiGraph` object + A separate directed acyclic graph (DAG) that includes explicit nodes for unobserved confounders, created using :func:`networkx.DiGraph`. +G : `networkx.DiGraph` object + Main graph G, which includes bidirected edges, and is created with :func:`networkx.DiGraph`. +G_obs : `networkx.DiGraph` object + A DAG that only includes directed edges, representing observed variables, created using :func:`networkx.DiGraph`. +topo : list of nodes + The topological ordering of the vertices in graph `G`, which can be obtained using :func:`networkx.topological_sort`. + +Returns +------- +Section in-progress + +Dependencies +------- +This function depends on several other functions and classes, including: +- :func:`powerset` +- :func:`is_d_separated` +- :func:`insert`. `insert` adds `new_variable` to `joint_dist_variables`. + +See Also +-------- +- :func:`simplify` +- :func:`is_d_separated` +- :func:`insert` + +Examples +-------- +Section in-progress +.. code-block:: python + + +Keywords +-------- +models, manip, math, utilities + +Concepts +-------- +probabilistic expressions, graph theory, causal inference + +References +---------- +Tikka, S. (2022). `causaleffect`: Deriving Expressions of Joint Interventional Distributions and Transport Formulas in Causal Models (1.3.15) [R package]. https://github.com/santikka/causaleffect/. +Tikka, S., & Karvanen, J. (2017). Simplifying probabilistic expressions in causal inference. Journal of Machine Learning Research, 18(36), 1-30. +Tikka, S., & Karvanen, J. (2018). Identifying causal effects with the R package causaleffect. arXiv preprint arXiv:1806.07161. + +Author +------ +Haley Hummel, +Psychology PhD student at Oregon State University + diff --git a/documentation/source/powerset.rst b/documentation/source/powerset.rst new file mode 100644 index 0000000..ccfd440 --- /dev/null +++ b/documentation/source/powerset.rst @@ -0,0 +1,45 @@ +Powerset +======== + +The `Powerset` function generates the power set of a given set. The power set is the set of all possible subsets of the original set, including the empty set and the set itself. + +Parameters +---------- +set : list + A list representing the original set for which the power set will be generated. The set can contain any type of elements (e.g., numeric, string, or boolean). + +Details +------- +The function computes all possible combinations of the elements of the input set. This includes the empty subset, individual elements, and all larger subsets up to and including the full set. The number of subsets in the power set of a set of size `n` is `2^n`. + +Returns +------- +list of lists + A list of lists, where each inner list is a subset of the original input set. The list contains `2^n` subsets, where `n` is the length of the input set. If the input set is empty, the function returns a list containing only the empty set. + +Examples +-------- +Section in-progress +.. code-block:: python + + +See Also +-------- +- `join`: for using :func:`powerset` with conditional independence in probabilistic graphical models. + +Keywords +-------- +set theory, combinatorics + +Concepts +-------- +power set, subsets + +References +---------- +Tikka, S., & Karvanen, J. (2017). Simplifying probabilistic expressions in causal inference. Journal of Machine Learning Research, 18(36), 1-30. + +Author +------ +Haley Hummel, +Psychology PhD student at Oregon State University diff --git a/documentation/source/simplify.rst b/documentation/source/simplify.rst new file mode 100644 index 0000000..5ec710c --- /dev/null +++ b/documentation/source/simplify.rst @@ -0,0 +1,69 @@ +Simplify +======== + +This function algebraically simplifies probabilistic expressions given by the ID algorithm from :func:`identify`. It always attempts to perform maximal simplification, meaning that as many variables of the set are +removed as possible. If the simplification in terms of the entire set cannot be completed, the intermediate result with as many variables simplified as possible should be returned. + +Run :func:`identify` with the graph information first, then use the output of :func:`identify` as the `prob_expression` in :func:`parse_causaleffect`. Use the output from :func:`parse_causaleffect` as the `prob_expression` in :func:`simplify`. + +For further information, see Tikka & Karvanen (2017) "Simplifying Probabilistic Expressions in Causal Inference" Algorithm 1. + + +Parameters +---------- +prob_expression : `sympy` expression or `y0` `Probability` object + Equivalent to `P` in Tikka's `causaleffect` R package. + The probabilistic expression that will be simplified, typically created using symbolic expressions in `sympy` or using `y0`'s Probability class. +topo : list of nodes + The topological ordering of the vertices in graph `G`, which can be obtained using :func:`networkx.topological_sort`. +G_unobs : `networkx.DiGraph` object + A separate directed acyclic graph (DAG) that includes explicit nodes for unobserved confounders, created using :func:`networkx.DiGraph`. +G : `networkx.DiGraph` object + Main graph G, which includes bidirected edges, and is created with :func:`networkx.DiGraph`. +G_obs : `networkx.DiGraph` object + A DAG that only includes directed edges, representing observed variables, created using :func:`networkx.DiGraph`. + +Details +------- +This function depends on several other functions and classes, including: +- :func:`parents` +- :func:`ancestors` +- :func:`parse_causaleffect` +- :func:`is_d_separated` +- :class:`probability` + +Returns +------- +list + Section in-progress + +References +---------- +Tikka, S., & Karvanen, J. (2017). Simplifying probabilistic expressions in causal inference. Journal of Machine Learning Research, 18(36), 1-30. + + +See Also +-------- +- :func:`identify` +- :func:`parse_causaleffect` +- :func:`get.expression` +- :class:`probability` + +Examples +-------- +Section in-progress + +.. code-block:: python + + +Keywords +-------- +models, manip, math, utilities +Concepts +-------- +probabilistic expressions, graph theory, causal inference + +Author +------ +Haley Hummel, +Psychology PhD student at Oregon State University \ No newline at end of file diff --git a/unit_tests/my_virtual_env/bin/Activate.ps1 b/unit_tests/my_virtual_env/bin/Activate.ps1 new file mode 100644 index 0000000..b49d77b --- /dev/null +++ b/unit_tests/my_virtual_env/bin/Activate.ps1 @@ -0,0 +1,247 @@ +<# +.Synopsis +Activate a Python virtual environment for the current PowerShell session. + +.Description +Pushes the python executable for a virtual environment to the front of the +$Env:PATH environment variable and sets the prompt to signify that you are +in a Python virtual environment. Makes use of the command line switches as +well as the `pyvenv.cfg` file values present in the virtual environment. + +.Parameter VenvDir +Path to the directory that contains the virtual environment to activate. The +default value for this is the parent of the directory that the Activate.ps1 +script is located within. + +.Parameter Prompt +The prompt prefix to display when this virtual environment is activated. By +default, this prompt is the name of the virtual environment folder (VenvDir) +surrounded by parentheses and followed by a single space (ie. '(.venv) '). + +.Example +Activate.ps1 +Activates the Python virtual environment that contains the Activate.ps1 script. + +.Example +Activate.ps1 -Verbose +Activates the Python virtual environment that contains the Activate.ps1 script, +and shows extra information about the activation as it executes. + +.Example +Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv +Activates the Python virtual environment located in the specified location. + +.Example +Activate.ps1 -Prompt "MyPython" +Activates the Python virtual environment that contains the Activate.ps1 script, +and prefixes the current prompt with the specified string (surrounded in +parentheses) while the virtual environment is active. + +.Notes +On Windows, it may be required to enable this Activate.ps1 script by setting the +execution policy for the user. You can do this by issuing the following PowerShell +command: + +PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + +For more information on Execution Policies: +https://go.microsoft.com/fwlink/?LinkID=135170 + +#> +Param( + [Parameter(Mandatory = $false)] + [String] + $VenvDir, + [Parameter(Mandatory = $false)] + [String] + $Prompt +) + +<# Function declarations --------------------------------------------------- #> + +<# +.Synopsis +Remove all shell session elements added by the Activate script, including the +addition of the virtual environment's Python executable from the beginning of +the PATH variable. + +.Parameter NonDestructive +If present, do not remove this function from the global namespace for the +session. + +#> +function global:deactivate ([switch]$NonDestructive) { + # Revert to original values + + # The prior prompt: + if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { + Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt + Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT + } + + # The prior PYTHONHOME: + if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { + Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME + Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME + } + + # The prior PATH: + if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { + Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH + Remove-Item -Path Env:_OLD_VIRTUAL_PATH + } + + # Just remove the VIRTUAL_ENV altogether: + if (Test-Path -Path Env:VIRTUAL_ENV) { + Remove-Item -Path env:VIRTUAL_ENV + } + + # Just remove VIRTUAL_ENV_PROMPT altogether. + if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) { + Remove-Item -Path env:VIRTUAL_ENV_PROMPT + } + + # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: + if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { + Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force + } + + # Leave deactivate function in the global namespace if requested: + if (-not $NonDestructive) { + Remove-Item -Path function:deactivate + } +} + +<# +.Description +Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the +given folder, and returns them in a map. + +For each line in the pyvenv.cfg file, if that line can be parsed into exactly +two strings separated by `=` (with any amount of whitespace surrounding the =) +then it is considered a `key = value` line. The left hand string is the key, +the right hand is the value. + +If the value starts with a `'` or a `"` then the first and last character is +stripped from the value before being captured. + +.Parameter ConfigDir +Path to the directory that contains the `pyvenv.cfg` file. +#> +function Get-PyVenvConfig( + [String] + $ConfigDir +) { + Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" + + # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue). + $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue + + # An empty map will be returned if no config file is found. + $pyvenvConfig = @{ } + + if ($pyvenvConfigPath) { + + Write-Verbose "File exists, parse `key = value` lines" + $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath + + $pyvenvConfigContent | ForEach-Object { + $keyval = $PSItem -split "\s*=\s*", 2 + if ($keyval[0] -and $keyval[1]) { + $val = $keyval[1] + + # Remove extraneous quotations around a string value. + if ("'""".Contains($val.Substring(0, 1))) { + $val = $val.Substring(1, $val.Length - 2) + } + + $pyvenvConfig[$keyval[0]] = $val + Write-Verbose "Adding Key: '$($keyval[0])'='$val'" + } + } + } + return $pyvenvConfig +} + + +<# Begin Activate script --------------------------------------------------- #> + +# Determine the containing directory of this script +$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition +$VenvExecDir = Get-Item -Path $VenvExecPath + +Write-Verbose "Activation script is located in path: '$VenvExecPath'" +Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)" +Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)" + +# Set values required in priority: CmdLine, ConfigFile, Default +# First, get the location of the virtual environment, it might not be +# VenvExecDir if specified on the command line. +if ($VenvDir) { + Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values" +} +else { + Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir." + $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/") + Write-Verbose "VenvDir=$VenvDir" +} + +# Next, read the `pyvenv.cfg` file to determine any required value such +# as `prompt`. +$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir + +# Next, set the prompt from the command line, or the config file, or +# just use the name of the virtual environment folder. +if ($Prompt) { + Write-Verbose "Prompt specified as argument, using '$Prompt'" +} +else { + Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value" + if ($pyvenvCfg -and $pyvenvCfg['prompt']) { + Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'" + $Prompt = $pyvenvCfg['prompt']; + } + else { + Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)" + Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'" + $Prompt = Split-Path -Path $venvDir -Leaf + } +} + +Write-Verbose "Prompt = '$Prompt'" +Write-Verbose "VenvDir='$VenvDir'" + +# Deactivate any currently active virtual environment, but leave the +# deactivate function in place. +deactivate -nondestructive + +# Now set the environment variable VIRTUAL_ENV, used by many tools to determine +# that there is an activated venv. +$env:VIRTUAL_ENV = $VenvDir + +if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) { + + Write-Verbose "Setting prompt to '$Prompt'" + + # Set the prompt to include the env name + # Make sure _OLD_VIRTUAL_PROMPT is global + function global:_OLD_VIRTUAL_PROMPT { "" } + Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT + New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt + + function global:prompt { + Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " + _OLD_VIRTUAL_PROMPT + } + $env:VIRTUAL_ENV_PROMPT = $Prompt +} + +# Clear PYTHONHOME +if (Test-Path -Path Env:PYTHONHOME) { + Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME + Remove-Item -Path Env:PYTHONHOME +} + +# Add the venv to the PATH +Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH +$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH" diff --git a/unit_tests/my_virtual_env/bin/activate b/unit_tests/my_virtual_env/bin/activate new file mode 100644 index 0000000..177e080 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/activate @@ -0,0 +1,63 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + # reset old environment variables + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then + PATH="${_OLD_VIRTUAL_PATH:-}" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then + PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # Call hash to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + hash -r 2> /dev/null + + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then + PS1="${_OLD_VIRTUAL_PS1:-}" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + unset VIRTUAL_ENV_PROMPT + if [ ! "${1:-}" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +# unset PYTHONHOME if set +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) +# could use `if (set -u; : $PYTHONHOME) ;` in bash +if [ -n "${PYTHONHOME:-}" ] ; then + _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" + unset PYTHONHOME +fi + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then + _OLD_VIRTUAL_PS1="${PS1:-}" + PS1="(my_virtual_env) ${PS1:-}" + export PS1 + VIRTUAL_ENV_PROMPT="(my_virtual_env) " + export VIRTUAL_ENV_PROMPT +fi + +# Call hash to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +hash -r 2> /dev/null diff --git a/unit_tests/my_virtual_env/bin/activate.csh b/unit_tests/my_virtual_env/bin/activate.csh new file mode 100644 index 0000000..a7f5ba4 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/activate.csh @@ -0,0 +1,26 @@ +# This file must be used with "source bin/activate.csh" *from csh*. +# You cannot run it directly. +# Created by Davide Di Blasi . +# Ported to Python 3.3 venv by Andrew Svetlov + +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate' + +# Unset irrelevant variables. +deactivate nondestructive + +setenv VIRTUAL_ENV "/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env" + +set _OLD_VIRTUAL_PATH="$PATH" +setenv PATH "$VIRTUAL_ENV/bin:$PATH" + + +set _OLD_VIRTUAL_PROMPT="$prompt" + +if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then + set prompt = "(my_virtual_env) $prompt" + setenv VIRTUAL_ENV_PROMPT "(my_virtual_env) " +endif + +alias pydoc python -m pydoc + +rehash diff --git a/unit_tests/my_virtual_env/bin/activate.fish b/unit_tests/my_virtual_env/bin/activate.fish new file mode 100644 index 0000000..7447dae --- /dev/null +++ b/unit_tests/my_virtual_env/bin/activate.fish @@ -0,0 +1,69 @@ +# This file must be used with "source /bin/activate.fish" *from fish* +# (https://fishshell.com/); you cannot run it directly. + +function deactivate -d "Exit virtual environment and return to normal shell environment" + # reset old environment variables + if test -n "$_OLD_VIRTUAL_PATH" + set -gx PATH $_OLD_VIRTUAL_PATH + set -e _OLD_VIRTUAL_PATH + end + if test -n "$_OLD_VIRTUAL_PYTHONHOME" + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME + set -e _OLD_VIRTUAL_PYTHONHOME + end + + if test -n "$_OLD_FISH_PROMPT_OVERRIDE" + set -e _OLD_FISH_PROMPT_OVERRIDE + # prevents error when using nested fish instances (Issue #93858) + if functions -q _old_fish_prompt + functions -e fish_prompt + functions -c _old_fish_prompt fish_prompt + functions -e _old_fish_prompt + end + end + + set -e VIRTUAL_ENV + set -e VIRTUAL_ENV_PROMPT + if test "$argv[1]" != "nondestructive" + # Self-destruct! + functions -e deactivate + end +end + +# Unset irrelevant variables. +deactivate nondestructive + +set -gx VIRTUAL_ENV "/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env" + +set -gx _OLD_VIRTUAL_PATH $PATH +set -gx PATH "$VIRTUAL_ENV/bin" $PATH + +# Unset PYTHONHOME if set. +if set -q PYTHONHOME + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME + set -e PYTHONHOME +end + +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" + # fish uses a function instead of an env var to generate the prompt. + + # Save the current fish_prompt function as the function _old_fish_prompt. + functions -c fish_prompt _old_fish_prompt + + # With the original prompt function renamed, we can override with our own. + function fish_prompt + # Save the return status of the last command. + set -l old_status $status + + # Output the venv prompt; color taken from the blue of the Python logo. + printf "%s%s%s" (set_color 4B8BBE) "(my_virtual_env) " (set_color normal) + + # Restore the return status of the previous command. + echo "exit $old_status" | . + # Output the original/"old" prompt. + _old_fish_prompt + end + + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" + set -gx VIRTUAL_ENV_PROMPT "(my_virtual_env) " +end diff --git a/unit_tests/my_virtual_env/bin/debugpy b/unit_tests/my_virtual_env/bin/debugpy new file mode 100755 index 0000000..bca7543 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/debugpy @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from debugpy.server.cli import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/unit_tests/my_virtual_env/bin/ipython b/unit_tests/my_virtual_env/bin/ipython new file mode 100755 index 0000000..79c63f3 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/ipython @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from IPython import start_ipython +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(start_ipython()) diff --git a/unit_tests/my_virtual_env/bin/ipython3 b/unit_tests/my_virtual_env/bin/ipython3 new file mode 100755 index 0000000..79c63f3 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/ipython3 @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from IPython import start_ipython +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(start_ipython()) diff --git a/unit_tests/my_virtual_env/bin/jupyter b/unit_tests/my_virtual_env/bin/jupyter new file mode 100755 index 0000000..b4a7908 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/jupyter @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from jupyter_core.command import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/unit_tests/my_virtual_env/bin/jupyter-kernel b/unit_tests/my_virtual_env/bin/jupyter-kernel new file mode 100755 index 0000000..04834e3 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/jupyter-kernel @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from jupyter_client.kernelapp import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/unit_tests/my_virtual_env/bin/jupyter-kernelspec b/unit_tests/my_virtual_env/bin/jupyter-kernelspec new file mode 100755 index 0000000..c837ab8 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/jupyter-kernelspec @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from jupyter_client.kernelspecapp import KernelSpecApp +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(KernelSpecApp.launch_instance()) diff --git a/unit_tests/my_virtual_env/bin/jupyter-migrate b/unit_tests/my_virtual_env/bin/jupyter-migrate new file mode 100755 index 0000000..f08327c --- /dev/null +++ b/unit_tests/my_virtual_env/bin/jupyter-migrate @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from jupyter_core.migrate import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/unit_tests/my_virtual_env/bin/jupyter-run b/unit_tests/my_virtual_env/bin/jupyter-run new file mode 100755 index 0000000..2a1c887 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/jupyter-run @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from jupyter_client.runapp import RunApp +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(RunApp.launch_instance()) diff --git a/unit_tests/my_virtual_env/bin/jupyter-troubleshoot b/unit_tests/my_virtual_env/bin/jupyter-troubleshoot new file mode 100755 index 0000000..2e67a10 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/jupyter-troubleshoot @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from jupyter_core.troubleshoot import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/unit_tests/my_virtual_env/bin/pip b/unit_tests/my_virtual_env/bin/pip new file mode 100755 index 0000000..88ee71f --- /dev/null +++ b/unit_tests/my_virtual_env/bin/pip @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/unit_tests/my_virtual_env/bin/pip3 b/unit_tests/my_virtual_env/bin/pip3 new file mode 100755 index 0000000..88ee71f --- /dev/null +++ b/unit_tests/my_virtual_env/bin/pip3 @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/unit_tests/my_virtual_env/bin/pip3.11 b/unit_tests/my_virtual_env/bin/pip3.11 new file mode 100755 index 0000000..88ee71f --- /dev/null +++ b/unit_tests/my_virtual_env/bin/pip3.11 @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/unit_tests/my_virtual_env/bin/pygmentize b/unit_tests/my_virtual_env/bin/pygmentize new file mode 100755 index 0000000..0f211c3 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/pygmentize @@ -0,0 +1,8 @@ +#!/Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env/bin/python3.11 +# -*- coding: utf-8 -*- +import re +import sys +from pygments.cmdline import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/unit_tests/my_virtual_env/bin/python b/unit_tests/my_virtual_env/bin/python new file mode 120000 index 0000000..6e7f3c7 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/python @@ -0,0 +1 @@ +python3.11 \ No newline at end of file diff --git a/unit_tests/my_virtual_env/bin/python3 b/unit_tests/my_virtual_env/bin/python3 new file mode 120000 index 0000000..6e7f3c7 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/python3 @@ -0,0 +1 @@ +python3.11 \ No newline at end of file diff --git a/unit_tests/my_virtual_env/bin/python3.11 b/unit_tests/my_virtual_env/bin/python3.11 new file mode 120000 index 0000000..2d17577 --- /dev/null +++ b/unit_tests/my_virtual_env/bin/python3.11 @@ -0,0 +1 @@ +/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11 \ No newline at end of file diff --git a/unit_tests/my_virtual_env/pyvenv.cfg b/unit_tests/my_virtual_env/pyvenv.cfg new file mode 100644 index 0000000..8e7f92b --- /dev/null +++ b/unit_tests/my_virtual_env/pyvenv.cfg @@ -0,0 +1,5 @@ +home = /Library/Frameworks/Python.framework/Versions/3.11/bin +include-system-site-packages = false +version = 3.11.9 +executable = /Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11 +command = /Library/Frameworks/Python.framework/Versions/3.11/bin/python3 -m venv /Users/humm249/Projects/Python/causaleffectpy/unit_tests/my_virtual_env diff --git a/unit_tests/my_virtual_env/share/jupyter/kernels/python3/kernel.json b/unit_tests/my_virtual_env/share/jupyter/kernels/python3/kernel.json new file mode 100644 index 0000000..cca38a4 --- /dev/null +++ b/unit_tests/my_virtual_env/share/jupyter/kernels/python3/kernel.json @@ -0,0 +1,14 @@ +{ + "argv": [ + "python", + "-m", + "ipykernel_launcher", + "-f", + "{connection_file}" + ], + "display_name": "Python 3 (ipykernel)", + "language": "python", + "metadata": { + "debugger": true + } +} \ No newline at end of file diff --git a/unit_tests/my_virtual_env/share/jupyter/kernels/python3/logo-32x32.png b/unit_tests/my_virtual_env/share/jupyter/kernels/python3/logo-32x32.png new file mode 100644 index 0000000..be81330 Binary files /dev/null and b/unit_tests/my_virtual_env/share/jupyter/kernels/python3/logo-32x32.png differ diff --git a/unit_tests/my_virtual_env/share/jupyter/kernels/python3/logo-64x64.png b/unit_tests/my_virtual_env/share/jupyter/kernels/python3/logo-64x64.png new file mode 100644 index 0000000..eebbff6 Binary files /dev/null and b/unit_tests/my_virtual_env/share/jupyter/kernels/python3/logo-64x64.png differ diff --git a/unit_tests/my_virtual_env/share/jupyter/kernels/python3/logo-svg.svg b/unit_tests/my_virtual_env/share/jupyter/kernels/python3/logo-svg.svg new file mode 100644 index 0000000..467b07b --- /dev/null +++ b/unit_tests/my_virtual_env/share/jupyter/kernels/python3/logo-svg.svg @@ -0,0 +1,265 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/unit_tests/my_virtual_env/share/man/man1/ipython.1 b/unit_tests/my_virtual_env/share/man/man1/ipython.1 new file mode 100644 index 0000000..0f4a191 --- /dev/null +++ b/unit_tests/my_virtual_env/share/man/man1/ipython.1 @@ -0,0 +1,60 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH IPYTHON 1 "July 15, 2011" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) and groff_man(7) +.\" .SH section heading +.\" .SS secondary section heading +.\" +.\" +.\" To preview this page as plain text: nroff -man ipython.1 +.\" +.SH NAME +ipython \- Tools for Interactive Computing in Python. +.SH SYNOPSIS +.B ipython +.RI [ options ] " files" ... + +.B ipython subcommand +.RI [ options ] ... + +.SH DESCRIPTION +An interactive Python shell with automatic history (input and output), dynamic +object introspection, easier configuration, command completion, access to the +system shell, integration with numerical and scientific computing tools, +web notebook, Qt console, and more. + +For more information on how to use IPython, see 'ipython \-\-help', +or 'ipython \-\-help\-all' for all available command\(hyline options. + +.SH "ENVIRONMENT VARIABLES" +.sp +.PP +\fIIPYTHONDIR\fR +.RS 4 +This is the location where IPython stores all its configuration files. The default +is $HOME/.ipython if IPYTHONDIR is not defined. + +You can see the computed value of IPYTHONDIR with `ipython locate`. + +.SH FILES + +IPython uses various configuration files stored in profiles within IPYTHONDIR. +To generate the default configuration files and start configuring IPython, +do 'ipython profile create', and edit '*_config.py' files located in +IPYTHONDIR/profile_default. + +.SH AUTHORS +IPython is written by the IPython Development Team . diff --git a/unit_tests/test_case_1.ipynb b/unit_tests/test_case_1.ipynb new file mode 100644 index 0000000..0845cde --- /dev/null +++ b/unit_tests/test_case_1.ipynb @@ -0,0 +1,364 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: pandas in ./my_virtual_env/lib/python3.11/site-packages (2.2.2)\r\n", + "Requirement already satisfied: numpy>=1.23.2 in ./my_virtual_env/lib/python3.11/site-packages (from pandas) (2.1.0)\r\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in ./my_virtual_env/lib/python3.11/site-packages (from pandas) (2.9.0.post0)\r\n", + "Requirement already satisfied: pytz>=2020.1 in ./my_virtual_env/lib/python3.11/site-packages (from pandas) (2024.1)\r\n", + "Requirement already satisfied: tzdata>=2022.7 in ./my_virtual_env/lib/python3.11/site-packages (from pandas) (2024.1)\r\n", + "Requirement already satisfied: six>=1.5 in ./my_virtual_env/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)\r\n", + "Requirement already satisfied: pandas in ./my_virtual_env/lib/python3.11/site-packages (2.2.2)\r\n", + "Requirement already satisfied: numpy>=1.23.2 in ./my_virtual_env/lib/python3.11/site-packages (from pandas) (2.1.0)\r\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in ./my_virtual_env/lib/python3.11/site-packages (from pandas) (2.9.0.post0)\r\n", + "Requirement already satisfied: pytz>=2020.1 in ./my_virtual_env/lib/python3.11/site-packages (from pandas) (2024.1)\r\n", + "Requirement already satisfied: tzdata>=2022.7 in ./my_virtual_env/lib/python3.11/site-packages (from pandas) (2024.1)\r\n", + "Requirement already satisfied: six>=1.5 in ./my_virtual_env/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], + "source": [ + "# install pandas\n", + "%pip install pandas\n", + "\n", + "import pandas" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: pytest in ./my_virtual_env/lib/python3.11/site-packages (8.3.2)\r\n", + "Requirement already satisfied: iniconfig in ./my_virtual_env/lib/python3.11/site-packages (from pytest) (2.0.0)\r\n", + "Requirement already satisfied: packaging in ./my_virtual_env/lib/python3.11/site-packages (from pytest) (24.1)\r\n", + "Requirement already satisfied: pluggy<2,>=1.5 in ./my_virtual_env/lib/python3.11/site-packages (from pytest) (1.5.0)\r\n", + "Requirement already satisfied: pytest in ./my_virtual_env/lib/python3.11/site-packages (8.3.2)\r\n", + "Requirement already satisfied: iniconfig in ./my_virtual_env/lib/python3.11/site-packages (from pytest) (2.0.0)\r\n", + "Requirement already satisfied: packaging in ./my_virtual_env/lib/python3.11/site-packages (from pytest) (24.1)\r\n", + "Requirement already satisfied: pluggy<2,>=1.5 in ./my_virtual_env/lib/python3.11/site-packages (from pytest) (1.5.0)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], + "source": [ + "# install pytest\n", + "%pip install pytest\n", + "\n", + "import pytest" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Obtaining file:///Users/humm249/Projects/Python/causaleffectpy\r\n", + "Obtaining file:///Users/humm249/Projects/Python/causaleffectpy\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Installing build dependencies ... \u001b[?25l- Installing build dependencies ... \u001b[?25l-" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \b\\\b \b\\" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \b|\b \b|" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \b/\b \b/" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \b-\b \b-" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \b\\\b \b\\" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \b|\b \b|" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \b/\b \b/" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \b-\b \b-" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \bdone\r\n", + "\b \bdone\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[?25h Checking if build backend supports build_editable ... \u001b[?25ldone\r\n", + "\u001b[?25h Checking if build backend supports build_editable ... \u001b[?25ldone\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[?25h Getting requirements to build editable ... \u001b[?25l-\u001b[?25h Getting requirements to build editable ... \u001b[?25l-" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \bdone\r\n", + "\b \bdone\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[?25h Preparing editable metadata (pyproject.toml) ... \u001b[?25l-\u001b[?25h Preparing editable metadata (pyproject.toml) ... \u001b[?25l-" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \bdone\r\n", + "\u001b[?25hRequirement already satisfied: numpy>=1.15.1 in ./my_virtual_env/lib/python3.11/site-packages (from causaleffect==0.0.3) (2.1.0)\r\n", + "\b \bdone\r\n", + "\u001b[?25hRequirement already satisfied: numpy>=1.15.1 in ./my_virtual_env/lib/python3.11/site-packages (from causaleffect==0.0.3) (2.1.0)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting python-igraph>=0.8.3 (from causaleffect==0.0.3)\r\n", + "Collecting python-igraph>=0.8.3 (from causaleffect==0.0.3)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Downloading python_igraph-0.11.6-py3-none-any.whl.metadata (2.8 kB)\r\n", + " Downloading python_igraph-0.11.6-py3-none-any.whl.metadata (2.8 kB)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting igraph==0.11.6 (from python-igraph>=0.8.3->causaleffect==0.0.3)\r\n", + "Collecting igraph==0.11.6 (from python-igraph>=0.8.3->causaleffect==0.0.3)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Downloading igraph-0.11.6-cp39-abi3-macosx_10_9_x86_64.whl.metadata (3.9 kB)\r\n", + " Downloading igraph-0.11.6-cp39-abi3-macosx_10_9_x86_64.whl.metadata (3.9 kB)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting texttable>=1.6.2 (from igraph==0.11.6->python-igraph>=0.8.3->causaleffect==0.0.3)\r\n", + "Collecting texttable>=1.6.2 (from igraph==0.11.6->python-igraph>=0.8.3->causaleffect==0.0.3)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Downloading texttable-1.7.0-py2.py3-none-any.whl.metadata (9.8 kB)\r\n", + " Downloading texttable-1.7.0-py2.py3-none-any.whl.metadata (9.8 kB)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Downloading python_igraph-0.11.6-py3-none-any.whl (9.1 kB)\r\n", + "Downloading python_igraph-0.11.6-py3-none-any.whl (9.1 kB)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Downloading igraph-0.11.6-cp39-abi3-macosx_10_9_x86_64.whl (1.9 MB)\r\n", + "\u001b[?25l \u001b[38;5;237m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/1.9 MB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0mDownloading igraph-0.11.6-cp39-abi3-macosx_10_9_x86_64.whl (1.9 MB)\r\n", + "\u001b[?25l \u001b[38;5;237m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/1.9 MB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\r\u001b[2K \u001b[38;5;237m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/1.9 MB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[38;5;237m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/1.9 MB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\r\u001b[2K \u001b[38;2;249;38;114m━━━━━━━━━━\u001b[0m\u001b[38;2;249;38;114m╸\u001b[0m\u001b[38;5;237m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.5/1.9 MB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[38;2;249;38;114m━━━━━━━━━━\u001b[0m\u001b[38;2;249;38;114m╸\u001b[0m\u001b[38;5;237m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.5/1.9 MB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\r\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.9/1.9 MB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\r\n", + "\u001b[?25h\r\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.9/1.9 MB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\r\n", + "\u001b[?25h" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Downloading texttable-1.7.0-py2.py3-none-any.whl (10 kB)\r\n", + "Downloading texttable-1.7.0-py2.py3-none-any.whl (10 kB)\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Building wheels for collected packages: causaleffect\r\n", + "Building wheels for collected packages: causaleffect\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Building editable for causaleffect (pyproject.toml) ... \u001b[?25l- Building editable for causaleffect (pyproject.toml) ... \u001b[?25l-" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\b \bdone\r\n", + "\u001b[?25h Created wheel for causaleffect: filename=causaleffect-0.0.3-0.editable-py3-none-any.whl size=4061 sha256=b2b658b635aa1c0dcacd53076702411d60eae4b096443cc0b405caa05818682d\r\n", + " Stored in directory: /private/var/folders/yf/ktb829fn4tzbj2g9n9ql66b40000gn/T/pip-ephem-wheel-cache-fjlfqlbi/wheels/c6/90/72/dff0a54dd92cb55268e141ec018397e5019a4431a393503fb3\r\n", + "Successfully built causaleffect\r\n", + "\b \bdone\r\n", + "\u001b[?25h Created wheel for causaleffect: filename=causaleffect-0.0.3-0.editable-py3-none-any.whl size=4061 sha256=b2b658b635aa1c0dcacd53076702411d60eae4b096443cc0b405caa05818682d\r\n", + " Stored in directory: /private/var/folders/yf/ktb829fn4tzbj2g9n9ql66b40000gn/T/pip-ephem-wheel-cache-fjlfqlbi/wheels/c6/90/72/dff0a54dd92cb55268e141ec018397e5019a4431a393503fb3\r\n", + "Successfully built causaleffect\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Installing collected packages: texttable, igraph, python-igraph, causaleffect\r\n", + "Installing collected packages: texttable, igraph, python-igraph, causaleffect\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Successfully installed causaleffect-0.0.3 igraph-0.11.6 python-igraph-0.11.6 texttable-1.7.0\r\n", + "Successfully installed causaleffect-0.0.3 igraph-0.11.6 python-igraph-0.11.6 texttable-1.7.0\r\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], + "source": [ + "# install causaleffectpy\n", + "%pip install -e .." + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}