Skip to content

Commit

Permalink
Rename spacetime module to spacetimelib
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtamohler committed Sep 14, 2023
1 parent c99b703 commit 4163b36
Show file tree
Hide file tree
Showing 20 changed files with 109 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: spacetime
activate-environment: spacetimelib
environment-file: environment.yaml
python-version: ${{ matrix.python-version }}
auto-activate-base: false
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Conda list
run: conda list

- name: Build spacetime
- name: Build spacetimelib
shell: bash -el {0}
run: |
python setup.py install
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ pip install spacetimelib
Install Miniconda:
[instructions](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html)

Clone SpacetimeLib the repository.

```bash
https://github.com/kurtamohler/spacetimelib.git && cd spacetimelib
```

Run the following to create and activate an environment with all dependencies.

```bash
conda env create -f environment.yaml -n spacetime && conda activate spacetime
conda env create -f environment.yaml -n spacetimelib && conda activate spacetimelib
```

Then install SpacetimeLib.
Expand Down
18 changes: 9 additions & 9 deletions doc/source/api-reference.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
API Reference
=============

.. autofunction:: spacetime.norm_s
.. autofunction:: spacetimelib.norm_s

.. autofunction:: spacetime.norm2_st
.. autofunction:: spacetimelib.norm2_st

.. autofunction:: spacetime.velocity_st
.. autofunction:: spacetimelib.velocity_st

.. autofunction:: spacetime.velocity_s
.. autofunction:: spacetimelib.velocity_s

.. autofunction:: spacetime.boost
.. autofunction:: spacetimelib.boost

.. autofunction:: spacetime.boost_velocity_s
.. autofunction:: spacetimelib.boost_velocity_s

.. autofunction:: spacetime.proper_time_delta
.. autofunction:: spacetimelib.proper_time_delta

.. autoclass:: spacetime.Worldline
.. autoclass:: spacetimelib.Worldline
:members:

.. automethod:: __len__
Expand All @@ -26,7 +26,7 @@ API Reference

.. automethod:: __eq__

.. autoclass:: spacetime.Frame
.. autoclass:: spacetimelib.Frame
:members:

.. automethod:: __len__
Expand Down
14 changes: 7 additions & 7 deletions doc/source/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ terminology.
To find the distance between two points, we take the norm of the difference between
them, and in general, we can take the norm of any vector.

We can use [`spacetime.norm_s`](spacetime.norm_s) to calculate the norm of any
We can use [`spacetimelib.norm_s`](spacetimelib.norm_s) to calculate the norm of any
space-vector.

```python
Expand All @@ -93,7 +93,7 @@ space-vector.
5.0
```

We can use [`spacetime.norm2_st`](spacetime.norm2_st) to calculate the square
We can use [`spacetimelib.norm2_st`](spacetimelib.norm2_st) to calculate the square
norm of any spacetime-vector. The square norm is more convenient than the norm
itself, because the square norm of a spacetime-vector can be negative.

Expand Down Expand Up @@ -145,8 +145,8 @@ vN) / sqrt(1 - norm_s(v)**2)`.
The squared norm of a spacetime-velocity must always be equal to the negative
of the speed of light.

SpacetimeLib has the functions [`spacetime.velocity_st`](spacetime.velocity_st)
and [`spacetime.velocity_s`](spacetime.velocity_s) for converting
SpacetimeLib has the functions [`spacetimelib.velocity_st`](spacetimelib.velocity_st)
and [`spacetimelib.velocity_s`](spacetimelib.velocity_s) for converting
between the two kinds of velocity vectors.

```python
Expand Down Expand Up @@ -212,7 +212,7 @@ constant velocity with respect to each other and which share the same origin.
If we know the coordinates of some event in one of the frames, we can use the
[Lorentz transformation](https://en.wikipedia.org/wiki/Lorentz_transformation)
to find the event's coordinates in the other frame. In SpacetimeLib, the
[`spacetime.boost`](spacetime.boost) function performs a rotation-free Lorentz
[`spacetimelib.boost`](spacetimelib.boost) function performs a rotation-free Lorentz
transformation, also known as a Lorentz boost. A Lorentz boost is just
a Lorentz transformation in which the two reference frames' corresponding
spatial dimensions are pointed in the same directions. In other words, the
Expand All @@ -221,7 +221,7 @@ rotations.

### Boost example: Superhuman footrace

Let's look at an example problem that [`spacetime.boost`](spacetime.boost) can
Let's look at an example problem that [`spacetimelib.boost`](spacetimelib.boost) can
solve for us. Alice is watching a footrace of superhuman athletes. She stands
still at the starting line for the whole race, at `x = 0`, and the finish line
is 10 light-seconds away from her, at `x = 10`. The race begins at time `t = 0`
Expand All @@ -232,7 +232,7 @@ reaches the finish line at `t = (10 / 0.8) = 12.5` seconds.
In Alice's frame, the coordinates of the event when Bob passes the finish line
are given by the vector `(12.5, 10)`. But what are the coordinates of this same
event from Bob's perspective? Let's solve this with
[`spacetime.boost`](spacetime.boost). We'll plug in the coordinates of the
[`spacetimelib.boost`](spacetimelib.boost). We'll plug in the coordinates of the
event in Alice's reference frame and boost it by Bob's velocity, `0.8`, to get
the coordinates of the event in Bob's reference frame.

Expand Down
4 changes: 2 additions & 2 deletions doc/source/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git clone https://github.com/kurtamohler/spacetimelib.git && cd spacetimelib
Create conda environment.

```bash
conda env create -f environment.yaml -n spacetime && conda activate spacetime
conda env create -f environment.yaml -n spacetimelib && conda activate spacetimelib
```

Install SpacetimeLib.
Expand All @@ -27,7 +27,7 @@ pip install -e .
To access SpacetimeLib, import it into your Python code:

```python
>>> import spacetime as st
>>> import spacetimelib as st
```

Shorten the imported name to `st` for better code readability, but you can just
Expand Down
12 changes: 6 additions & 6 deletions doc/source/notebooks/Length contraction of a circle.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions doc/source/notebooks/Length contraction.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions doc/source/notebooks/Twin Paradox.ipynb

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions doc/source/notebooks/Worldline Tutorial.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ dependencies:
- matplotlib
- perfplot
- build
- twine
2 changes: 1 addition & 1 deletion examples/clock_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pygame
import numpy as np

from spacetime import Frame, boost, boost_velocity_s, Worldline
from spacetimelib import Frame, boost, boost_velocity_s, Worldline

rest_frame = Frame()

Expand Down
80 changes: 40 additions & 40 deletions notebooks/Performance.ipynb

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[build-system]
requires = [
"setuptools>=61.0",
"numpy",
"sphinx",
"myst-parser",
"myst-nb",
Expand All @@ -23,6 +22,9 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
'numpy',
]

[project.urls]
"Homepage" = "https://github.com/kurtamohler/spacetimelib"
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
with open('LICENSE') as f:
license = f.read()

name = 'spacetime'
name = 'spacetimelib'
version = '0.0'
release = '0.0.1'

Expand All @@ -23,7 +23,7 @@
author_email='kurtamohler@gmail.com',
url='https://github.com/kurtamohler/spacetimelib',
# license=license,
packages=['spacetime'],
packages=['spacetimelib'],
cmdclass=cmdclass,
# these are optional and override conf.py settings
command_options={
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions spacetime/basic_ops.py → spacetimelib/basic_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def velocity_st(vel_s, light_speed=1):
Spacetime-velocity is traditionally called four-velocity in the context of
3+1 Minkowski spacetime.
This is the reverse of :func:`spacetime.velocity_s`.
This is the reverse of :func:`spacetimelib.velocity_s`.
Args:
Expand Down Expand Up @@ -427,7 +427,7 @@ def velocity_s(vel_st):
'''
Calculates the space-velocity vector from a spacetime-velocity vector.
This is the reverse of :func:`spacetime.velocity_st`.
This is the reverse of :func:`spacetimelib.velocity_st`.
Args:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion spacetime/frame.py → spacetimelib/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from itertools import islice
import re

import spacetime as st
import spacetimelib as st
from .error_checking import check, internal_assert, maybe_wrap_index

class Frame:
Expand Down
10 changes: 5 additions & 5 deletions spacetime/worldline.py → spacetimelib/worldline.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import numbers

import spacetime as st
import spacetimelib as st
from .error_checking import check, internal_assert

class Worldline:
Expand Down Expand Up @@ -482,7 +482,7 @@ def boost(self, boost_vel_s):
Space-velocity to boost the worldline by.
Returns:
:class:`spacetime.Worldline`:
:class:`spacetimelib.Worldline`:
'''
vertices = st.boost(self._vertices, boost_vel_s)
past_vel_s = None
Expand Down Expand Up @@ -513,7 +513,7 @@ def __add__(self, event_delta):
Displacements to add to each dimension.
Returns:
:class:`spacetime.Worldline`:
:class:`spacetimelib.Worldline`:
'''
event_delta = np.asarray(event_delta)
check(event_delta.shape == self._vertices[0].shape, ValueError, lambda: (
Expand All @@ -537,7 +537,7 @@ def __sub__(self, event_delta):
Displacements to subtract from each dimension.
Returns:
:class:`spacetime.Worldline`:
:class:`spacetimelib.Worldline`:
'''
return self + (-event_delta)

Expand All @@ -548,7 +548,7 @@ def __eq__(self, other):
Args:
other (:class:`spacetime.Worldline`):
other (:class:`spacetimelib.Worldline`):
Other worldline
Returns:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_spacetime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import spacetime as st
import spacetimelib as st
import numpy as np
import unittest
from itertools import product
Expand Down Expand Up @@ -28,7 +28,7 @@ def check_boost_velocity_1D(v, u):
u = np.array(u)
return (u - v) / (1 - u * v)

class SpacetimeTestSuite(unittest.TestCase):
class SpacetimelibTestSuite(unittest.TestCase):

def test_norm_s(self):
test_sizes = [
Expand Down Expand Up @@ -403,7 +403,7 @@ def test_boost_velocity_1D_random(self):

self.assertTrue(np.isclose(u_out, u_out_check).all())

# Test `spacetime.boost` with lots of different input shapes
# Test `spacetimelib.boost` with lots of different input shapes
def test_boost_shapes(self):
input_shapes = [
# frame_v_shape, x_shape, u_shape, x_out_shape_check, u_out_shape_check
Expand Down

0 comments on commit 4163b36

Please sign in to comment.