Skip to content

Commit 9a4616f

Browse files
Merge pull request #55 from flatironinstitute/nemos
converted to nemos
2 parents 4bb837c + b2c771c commit 9a4616f

21 files changed

+128
-50
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build and upload to PyPI for pure python
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
build:
8+
name: Build and test package
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
# this is necessary for setuptools_scm to work properly with github
13+
# actions, see https://github.com/pypa/setuptools_scm/issues/480 and
14+
# https://stackoverflow.com/a/68959339
15+
with:
16+
fetch-depth: 0
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.x'
21+
- name: Build package
22+
run: |
23+
pip install build
24+
python -m build --outdir dist/ --sdist --wheel
25+
- name: Check there's only one sdist and one whl file created
26+
shell: bash
27+
# because the following two tests will be weird otherwise. see
28+
# https://askubuntu.com/a/454568 for why this is the right way to handle
29+
# it. using [[ BOOLEAN ]] || EXPR is a compact way of writing IF NOT
30+
# BOOLEAN THEN EXPR in bash
31+
run: |
32+
[[ $(find dist/ -type f -name "*whl" -printf x | wc -c) == 1 ]] || exit 1
33+
[[ $(find dist/ -type f -name "*tar.gz" -printf x | wc -c) == 1 ]] || exit 1
34+
- name: Check setuptools_scm version against git tag
35+
shell: bash
36+
run: |
37+
# we use the error code of this comparison: =~ is bash's regex
38+
# operator, so it checks whether the right side is contained in the
39+
# left side. In particular, we succeed if the path of the source code
40+
# ends in the most recent git tag, fail if it does not.
41+
[[ "$(ls dist/*tar.gz)" =~ "-$(git describe --tags).tar.gz" ]]
42+
- name: Check we can install from wheel
43+
# note that this is how this works in bash (different shells might be
44+
# slightly different). we've checked there's only one .whl file in an
45+
# earlier step, so the bit in `$()` will expand to that single file,
46+
# then we pass [dev] to get specify the optional dev dependencies, and
47+
# we wrap the whole thing in quotes so bash doesn't try to interpret the
48+
# square brackets but passes them directly to pip install
49+
shell: bash
50+
run: |
51+
pip install "$(ls dist/*whl)[dev]"
52+
- name: Run some tests
53+
# modify the following as necessary to e.g., run notebooks
54+
run: |
55+
pytest
56+
- uses: actions/upload-artifact@v3
57+
with:
58+
path: dist/*
59+
60+
publish:
61+
name: Upload release to Test PyPI
62+
needs: [build]
63+
environment: pypi
64+
runs-on: ubuntu-latest
65+
permissions:
66+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
67+
steps:
68+
- uses: actions/download-artifact@v3
69+
with:
70+
name: artifact
71+
path: dist
72+
- name: Publish package to test pypi
73+
uses: pypa/gh-action-pypi-publish@release/v1
74+
with:
75+
repository-url: https://test.pypi.org/legacy/

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing
22

3-
The `neurostatslib` package is designed to provide a robust set of statistical analysis tools for neuroscience research. While the repository is managed by a core team of data scientists at the Center for Computational Neuroscience of the Flatiron Institute, we warmly welcome contributions from external collaborators.
3+
The `nemos` package is designed to provide a robust set of statistical analysis tools for neuroscience research. While the repository is managed by a core team of data scientists at the Center for Computational Neuroscience of the Flatiron Institute, we warmly welcome contributions from external collaborators.
44

55
## General Guidelines
66

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
![LOGO](CCN-logo-wText.png)
22

3-
# neurostatslib
4-
A toolbox of statistical analysis for neuroscience.
3+
# nemos
4+
NEural MOdelS, a statistical modeling framework for neuroscience.
5+
6+
## Disclaimer
7+
This is an alpha version, the code is in active development and the API is subject to change.
58

69
## Setup
710

811
To install, clone this repo and install using `pip`:
912

1013
``` sh
11-
git clone [email protected]:flatironinstitute/generalized-linear-models.git
12-
cd generalized-linear-models/
14+
git clone [email protected]:flatironinstitute/nemos.git
15+
cd nemos/
1316
pip install -e .
1417
```
1518

docs/developers_notes/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Introduction
22

3-
Welcome to the Developer Notes of the `neurostatslib` project. These notes aim to provide detailed technical information about the various modules, classes, and functions that make up this library, as well as guidelines on how to write code that integrates nicely with our package. They are intended to help current and future developers understand the design decisions, structure, and functioning of the library, and to provide guidance on how to modify, extend, and maintain the codebase.
3+
Welcome to the Developer Notes of the `nemos` project. These notes aim to provide detailed technical information about the various modules, classes, and functions that make up this library, as well as guidelines on how to write code that integrates nicely with our package. They are intended to help current and future developers understand the design decisions, structure, and functioning of the library, and to provide guidance on how to modify, extend, and maintain the codebase.
44

55
## Intended Audience
66

@@ -10,25 +10,25 @@ These notes are primarily intended for the following groups:
1010

1111
- **Future Developers**: These notes can help onboard new developers to the project, providing them with detailed explanations of the codebase and its underlying architecture.
1212

13-
- **Contributors**: If you wish to contribute to the `neurostatslib` project, the Developer Notes can provide a solid foundation of understanding, helping to ensure that your contributions align with the existing structure and design principles of the library.
13+
- **Contributors**: If you wish to contribute to the `nemos` project, the Developer Notes can provide a solid foundation of understanding, helping to ensure that your contributions align with the existing structure and design principles of the library.
1414

1515
- **Advanced Users**: While the primary focus of these notes is on development, they might also be of interest to advanced users who want a deeper understanding of the library's functionality.
1616

1717
Please note that these notes assume a certain level of programming knowledge. Familiarity with Python, object-oriented programming, and the NumPy, Scipy and Jax libraries would be beneficial when reading these notes.
1818

1919
## Navigating the Developer Notes
2020

21-
The Developer Notes are divided into sections, each focusing on a different module or class within the `neurostatslib` library. Each section provides an overview of the class or module, explains its role and functionality within the library, and offers a comprehensive guide to its classes and functions. Typically, we will provide instructions on how to extend the existing modules. We generally advocate for the use of inheritance and encourage consistency with the existing codebase. In creating developer instructions, we follow the conventions outlined below:
21+
The Developer Notes are divided into sections, each focusing on a different module or class within the `nemos` library. Each section provides an overview of the class or module, explains its role and functionality within the library, and offers a comprehensive guide to its classes and functions. Typically, we will provide instructions on how to extend the existing modules. We generally advocate for the use of inheritance and encourage consistency with the existing codebase. In creating developer instructions, we follow the conventions outlined below:
2222

2323
- **Must**: This denotes a requirement. Any method or function that fails to meet the requirement will not be merged.
2424
- **Should**: This denotes a suggestion. Reasons should be provided if a suggestion is not followed.
2525
- **May**: This denotes an option that, if implemented, could enhance the user/developer experience but can be overlooked if deemed unnecessary.
2626

2727
## Interact with us
2828

29-
If you're considering contributing to the library, first of all, welcome aboard! As a first step, we recommend that you read the [`CONTRIBUTING.md`](https://github.com/flatironinstitute/generalized-linear-models/blob/main/CONTRIBUTING.md) guidelines. These will help you understand how to interact with other contributors and how to submit your changes.
29+
If you're considering contributing to the library, first of all, welcome aboard! As a first step, we recommend that you read the [`CONTRIBUTING.md`](https://github.com/flatironinstitute/nemos/blob/main/CONTRIBUTING.md) guidelines. These will help you understand how to interact with other contributors and how to submit your changes.
3030

31-
If you have any questions or need further clarification on any of the topics covered in these notes, please don't hesitate to reach out to us. You can do so via the [discussion](https://github.com/flatironinstitute/generalized-linear-models/discussions/landing) forum on GitHub.
31+
If you have any questions or need further clarification on any of the topics covered in these notes, please don't hesitate to reach out to us. You can do so via the [discussion](https://github.com/flatironinstitute/nemos/discussions/landing) forum on GitHub.
3232

3333
We're looking forward to your contributions and to answering any queries you might have!
3434

docs/developers_notes/basis_module.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Introduction
44

5-
The `neurostatslib.basis` module provides objects that allow users to construct and evaluate basis functions of various types. The classes are hierarchically organized as follows:
5+
The `nemos.basis` module provides objects that allow users to construct and evaluate basis functions of various types. The classes are hierarchically organized as follows:
66

77
```
88
Abstract Class Basis
@@ -30,7 +30,7 @@ Abstract Class Basis
3030

3131
The super-class `Basis` provides two public methods, [`evaluate`](#the-public-method-evaluate) and [`evaluate_on_grid`](#the-public-method-evaluate_on_grid). These methods perform checks on both the input provided by the user and the output of the evaluation to ensure correctness, and are thus considered "safe". They both make use of the private abstract method `_evaluate` that is specific for each concrete class. See below for more details.
3232

33-
## The Class `neurostatslib.basis.Basis`
33+
## The Class `nemos.basis.Basis`
3434

3535
### The Public Method `evaluate`
3636

@@ -54,7 +54,7 @@ This method performs the following steps:
5454

5555
### Abstract Methods
5656

57-
The `neurostatslib.basis.Basis` class has the following abstract methods, which every concrete subclass must implement:
57+
The `nemos.basis.Basis` class has the following abstract methods, which every concrete subclass must implement:
5858

5959
1. `_evaluate`: Evaluates a basis over some specified samples.
6060
2. `_check_n_basis_min`: Checks the minimum number of basis functions required. This requirement can be specific to the type of basis.
@@ -65,7 +65,7 @@ The `neurostatslib.basis.Basis` class has the following abstract methods, which
6565
To write a usable (i.e., concrete, non-abstract) basis object, you
6666

6767
- **Must** inherit the abstract superclass `Basis`
68-
- **Must** define the `_evaluate` and `_check_n_basis_min` methods with the expected input/output format, see [Code References](../../reference/neurostatslib/basis/) for the specifics.
68+
- **Must** define the `_evaluate` and `_check_n_basis_min` methods with the expected input/output format, see [Code References](../../reference/nemos/basis/) for the specifics.
6969
- **Should not** overwrite the `evaluate` and `evaluate_on_grid` methods inherited from `Basis`.
7070
- **May** inherit any number of abstract intermediate classes (e.g., `SplineBasis`).
7171
- **May** reimplement the `_get_samples` method if your basis domain differs from `[0,1]`. However, we recommend mapping the specific basis domain to `[0,1]` whenever possible.

docs/examples/plot_1D_basis_function.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515
import numpy as np
1616
import matplotlib.pylab as plt
17-
import neurostatslib as nsl
17+
import nemos as nmo
1818

1919
# Initialize hyperparameters
2020
order = 4
2121
n_basis = 10
2222

2323
# Define the 1D basis function object
24-
mspline_basis = nsl.basis.MSplineBasis(n_basis_funcs=n_basis, order=order)
24+
mspline_basis = nmo.basis.MSplineBasis(n_basis_funcs=n_basis, order=order)
2525

2626
# %%
2727
# Evaluating a Basis
@@ -63,12 +63,12 @@
6363
# Other Basis Types
6464
# -----------------
6565
# Each basis type may necessitate specific hyperparameters for instantiation. For a comprehensive description,
66-
# please refer to the [Code References](../../../reference/neurostatslib/basis). After instantiation, all classes
66+
# please refer to the [Code References](../../../reference/nemos/basis). After instantiation, all classes
6767
# share the same syntax for basis evaluation. The following is an example of how to instantiate and
6868
# evaluate a log-spaced cosine raised function basis.
6969

7070
# Instantiate the basis noting that the `RaisedCosineBasisLog` does not require an `order` parameter
71-
raised_cosine_log = nsl.basis.RaisedCosineBasisLog(n_basis_funcs=10)
71+
raised_cosine_log = nmo.basis.RaisedCosineBasisLog(n_basis_funcs=10)
7272

7373
# Evaluate the raised cosine basis at the equi-spaced sample points
7474
# (same method in all Basis elements)

docs/examples/plot_ND_basis_function.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@
6565

6666
import numpy as np
6767
import matplotlib.pyplot as plt
68-
import neurostatslib as nsl
68+
import nemos as nmo
6969

7070
# Define 1D basis objects
71-
a_basis = nsl.basis.MSplineBasis(n_basis_funcs=15, order=3)
72-
b_basis = nsl.basis.RaisedCosineBasisLog(n_basis_funcs=14)
71+
a_basis = nmo.basis.MSplineBasis(n_basis_funcs=15, order=3)
72+
b_basis = nmo.basis.RaisedCosineBasisLog(n_basis_funcs=14)
7373

7474
# Define the 2D additive basis object
7575
additive_basis = a_basis + b_basis
@@ -238,9 +238,9 @@
238238
T = 10
239239
n_basis = 8
240240

241-
a_basis = nsl.basis.RaisedCosineBasisLinear(n_basis_funcs=n_basis)
242-
b_basis = nsl.basis.RaisedCosineBasisLinear(n_basis_funcs=n_basis)
243-
c_basis = nsl.basis.RaisedCosineBasisLinear(n_basis_funcs=n_basis)
241+
a_basis = nmo.basis.RaisedCosineBasisLinear(n_basis_funcs=n_basis)
242+
b_basis = nmo.basis.RaisedCosineBasisLinear(n_basis_funcs=n_basis)
243+
c_basis = nmo.basis.RaisedCosineBasisLinear(n_basis_funcs=n_basis)
244244

245245
prod_basis_3 = a_basis * b_basis * c_basis
246246
samples = np.linspace(0, 1, T)

docs/examples/plot_example_convolution.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010
import matplotlib.pylab as plt
1111
import matplotlib.patches as patches
12-
import neurostatslib as nsl
12+
import nemos as nmo
1313

1414
np.random.seed(10)
1515
ws = 11
@@ -39,7 +39,7 @@
3939

4040

4141
# create three filters
42-
basis_obj = nsl.basis.RaisedCosineBasisLinear(n_basis_funcs=3)
42+
basis_obj = nmo.basis.RaisedCosineBasisLinear(n_basis_funcs=3)
4343
_, w = basis_obj.evaluate_on_grid(ws)
4444

4545
plt.plot(w)
@@ -48,7 +48,7 @@
4848
# the function requires an iterable (one element per trial)
4949
# and returns a list of convolutions
5050

51-
spk_conv = nsl.utils.convolve_1d_trials(w, [spk, np.zeros((20, 1))])
51+
spk_conv = nmo.utils.convolve_1d_trials(w, [spk, np.zeros((20, 1))])
5252
print(f"Shape of spk: {spk.shape}\nShape of w: {w.shape}")
5353

5454
# valid convolution should be of shape n_samples - ws + 1
@@ -72,9 +72,9 @@
7272

7373

7474
# pad according to the causal direction of the filter, after squeeze, the dimension is (n_filters, n_samples)
75-
spk_causal_utils = np.squeeze(nsl.utils.nan_pad_conv(spk_conv, ws, filter_type="causal")[0])
76-
spk_anticausal_utils = np.squeeze(nsl.utils.nan_pad_conv(spk_conv, ws, filter_type="anti-causal")[0])
77-
spk_acausal_utils = np.squeeze(nsl.utils.nan_pad_conv(spk_conv, ws, filter_type="acausal")[0])
75+
spk_causal_utils = np.squeeze(nmo.utils.nan_pad_conv(spk_conv, ws, filter_type="causal")[0])
76+
spk_anticausal_utils = np.squeeze(nmo.utils.nan_pad_conv(spk_conv, ws, filter_type="anti-causal")[0])
77+
spk_acausal_utils = np.squeeze(nmo.utils.nan_pad_conv(spk_conv, ws, filter_type="acausal")[0])
7878

7979

8080
# %%

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# neurostatslib
1+
# nemos
22
A toolbox of statistical analysis for neuroscience.
33

44
## Disclaimer
55
Please note that this package is currently under development. While you can download and test the functionalities that are already present, it's important to be aware that the code stability and systematic testing cannot be guaranteed at this stage.
66

7-
See our [README](https://github.com/flatironinstitute/generalized-linear-models/blob/main/README.md) for more info.
7+
See our [README](https://github.com/flatironinstitute/nemos/blob/main/README.md) for more info.

mkdocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
site_name: neurostatslib
2-
repo_url: https://github.com/flatironinstitute/generalized-linear-models
1+
site_name: nemos
2+
repo_url: https://github.com/flatironinstitute/nemos
33

44
theme:
55
name: 'material' # The theme name, using the 'material' theme

0 commit comments

Comments
 (0)