Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

#########################################
# keep version files in and manually update if needed
GIT_SHA
VERSION

#########################################
# Editor temporary/working/backup files #
.#*
Expand All @@ -10,6 +15,7 @@
.project
.pydevproject
.pdm-python
.python-version
/.ropeproject/config.py
/.ropeproject/history
/.ropeproject/objectdb
Expand All @@ -19,6 +25,7 @@
/.cache
/.idea
/.untitled.py
scratch.py

# Compiled source #
###################
Expand All @@ -32,6 +39,7 @@
*.so
*.egg
.eggs
psychopy/app/locale/**/LC_MESSAGE/messages.mo

# Python files #
################
Expand All @@ -47,6 +55,7 @@ dist
*.egg-info
# tox testing tool
.tox
.venv
# Moves icons from res to component folders
/dropoff/dropoff_dark.py
/dropoff/dropoff_light.py
Expand All @@ -67,9 +76,8 @@ nonSVN

# Things specific to this project #
###################################
PsyScope*
psychopy1
psychojs.zip
# pdm.lock will include platform-specific libs so not portable
# pdm.lock

psychopy/demos/coder/misc/frame*
psychopy/demos/**/data/*.psydat
Expand Down Expand Up @@ -106,9 +114,14 @@ gource_psychopy.mkv
*.hdf5
*.7z

# NSIS temp compilation files #
###############################
uninstallFiles.nsi

# Documentation generated files #
#################################
.coverage
#nonSphinx
/venv*/
/.venv*/
!psychopy
695 changes: 674 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
# psychopy-lib
# PsychoPy

This repo is a test of deploying just the lib for PsychoPy (without the application) for the sake of runtime environments that may want to run a PsychoPy study without the application.
[![PyPI version](https://img.shields.io/pypi/v/psychopy.svg)](https://pypi.python.org/pypi/PsychoPy)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](code-of-conduct.md)

As a result of not bundling the application this no longer depends on wxPython making it easier to install.
---

This is a work in progress and may not currently be synchronised with the main code in the psychopy repository.
PsychoPy is an open-source package for creating experiments in behavioral science. It aims to provide a single package that is:

* precise enough for psychophysics
* easy enough for teaching
* flexible enough for everything else
* able to run experiments in a local Python script or online in JavaScript

To meet these goals PsychoPy provides a choice of interface - you can use a
simple graphical user interface called Builder, or write your experiments in
Python code. The entire application and library are written in Python and is
platform independent.

There is a range of documentation at:

* [PsychoPy Homepage](https://www.psychopy.org)
* [Youtube](https://www.youtube.com/playlist?list=PLFB5A1BE51964D587)
* The textbook, [Building Experiments in PsychoPy](https://uk.sagepub.com/en-gb/eur/building-experiments-in-psychopy/book253480)
* [The discourse user forum](https://discourse.psychopy.org)

## Contributions

To contribute, please fork the repository, hack in a feature branch, and send a
pull request. For more, see [CONTRIBUTING.md](CONTRIBUTING.md)
and the developers documentation at [https://www.psychopy.org/developers](https://psychopy.org/developers)

## Code Status

Dev branch: [![GH tests dev](https://github.com/psychopy/psychopy/actions/workflows/pytests.yaml/badge.svg?branch=dev)](https://github.com/psychopy/psychopy/actions/workflows/pytests.yaml?query=branch%3Adev) [![CodeQL (dev)](https://github.com/psychopy/psychopy/actions/workflows/CodeQL.yaml/badge.svg?branch=dev)](https://github.com/psychopy/psychopy/actions/workflows/CodeQL.yaml?query=branch%3Adev)

Release branch: [![GH tests release](https://github.com/psychopy/psychopy/actions/workflows/pytests.yaml/badge.svg?branch=release)](https://github.com/psychopy/psychopy/actions/workflows/pytests.yaml?query=branch%3Arelease) [![CodeQL (release)](https://github.com/psychopy/psychopy/actions/workflows/CodeQL.yaml/badge.svg?branch=release)](https://github.com/psychopy/psychopy/actions/workflows/CodeQL.yaml?query=branch%3Arelease)

## More information

* Homepage: https://www.psychopy.org
* Forum: https://discourse.psychopy.org
* Issue tracker: https://github.com/psychopy/psychopy/issues
* Changelog: https://www.psychopy.org/changelog.html
124 changes: 0 additions & 124 deletions installPsychoPy.py

This file was deleted.

32 changes: 0 additions & 32 deletions pdm_build.py

This file was deleted.

2 changes: 1 addition & 1 deletion psychopy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2026.1.0
2026.2.1
19 changes: 19 additions & 0 deletions psychopy/alerts/alertsCatalogue/4215.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

code: 4215
cat: Coding
msg: quitPsychoJS needs to be returned

# The following are typically used for online help pages, and support reStructured Text.
label: quitPsychoJS needs to be returned

synopsis: |
The `quitPsychoJS` function needs to be preceeded by `return`, otherwise data will not be saved

details: |
In PsychoJS, each part of your experiment is inside of a function, and the values returned by these functions tell PsychoJS how to proceed once each one is done. Calling `quitPsychoJS` will end your experiment, but if the function you're in doesn't return anything then PsychoJS doesn't know to save your data.

solutions: |
Instead of calling `quitPsychoJS()`, you need to call `return quitPsychoJS()`.

versions: |
All versions.
1 change: 1 addition & 0 deletions psychopy/alerts/alertsCatalogue/alertCategories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
cat: Code component syntax
4205: Python syntax error
4210: JavaScript syntax error
4215: quitPsychoJS needs to be returned
4300:
cat: Components
4305: Component disabled
Expand Down
11 changes: 10 additions & 1 deletion psychopy/alerts/alerttools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ast
import re

from numpy import array
from esprima import parseScript
Expand Down Expand Up @@ -314,9 +315,17 @@ def checkJavaScriptSyntax(component, tab):
tab: str
The name of the code component tab being tested
"""
content = str(component.params[tab].val)
# check that value is valid syntax
try:
parseScript(str(component.params[tab].val))
parseScript(content)
except Exception as err:
strFields = {'codeTab': tab, 'lineNumber': err.message}
# Dont sent traceback because strFields gives better localisation of error
alert(4210, component, strFields)
# if quitPsychoJS is called, make sure it's returned
if re.match(
r"(?<!return )quitPsychoJS",
content
):
alert(4215, component)
9 changes: 8 additions & 1 deletion psychopy/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import psychopy.tools.colorspacetools as ct
from psychopy.tools.mathtools import infrange
import numpy as np
import ast


# Dict of examples of Psychopy Red at 12% opacity in different formats
Expand Down Expand Up @@ -282,6 +283,12 @@ def validate(self, color, space=None):
if isinstance(color, str):
if color == "":
color = "none"
# if given a string for anything other than hex or named, try to parse it to an array
if space not in ("named", "hex"):
try:
color = ast.literal_eval(color)
except (ValueError, SyntaxError):
pass
# Handle everything as an array
if not isinstance(color, np.ndarray):
color = np.array(color)
Expand Down Expand Up @@ -1052,7 +1059,7 @@ def isValidColor(color, space='rgb'):
try:
buffer = Color(color, space)
return bool(buffer)
except:
except Exception:
return False


Expand Down
2 changes: 1 addition & 1 deletion psychopy/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def _attemptImport(fileName):
raise err
# if it's all good, use received array
trialsArr = thisAttempt
except:
except Exception:
continue
else:
# if successful, check the variable names
Expand Down
Binary file not shown.
Loading
Loading